Package org.hibernate

Examples of org.hibernate.Session.save()


    public void saveNewPost(Posts post) {
  Session session = null;
  try {
      LOG.debug("Entering saveNewPost >> UserPostsDAOImpl");
      session = getSessionFactory().getCurrentSession();
      session.save(post);
  }
  catch (Exception e) {
      LOG.error("Error occured while saving a new post : " + e);
  }
  finally {
View Full Code Here


      String[] names = new String[]{"Friends","Family","Business"};
      for(int ii = 0; ii < names.length; ii++ )
      {
        Category category = new Category();
        category.setName(names[ii]);
        session.save(category)
        categories.put(ii, category);
      }

      Random random = new Random();
      int numberBase = 1;
View Full Code Here

          Contact contact = new Contact();
          contact.setFirstName(name[0]);
          contact.setLastName(name[1]);
          contact.setCategory(categories.get(random.nextInt(2)));
          contact.setPhoneNumber(String.format("800-555-%04d",numberBase++));
          session.save(contact)
        }
      }
      catch(IOException ex)
      {
        throw new RuntimeException(ex);
View Full Code Here

          associatedObject,
          sessionImplementor
      );
    }
    catch (TransientObjectException toe) {
      id = session.save( foreignValueSourceType.getAssociatedEntityName(), associatedObject );
    }

    if ( session.contains(object) ) {
      //abort the save (the object is already saved by a circular cascade)
      return IdentifierGeneratorHelper.SHORT_CIRCUIT_INDICATOR;
View Full Code Here

    Session session = null;
    Transaction tx = null;
    try {
      session = getSession();
      tx = beginTransaction();
      id = (Id) session.save(obj);
      commit(tx);
    } catch (HibernateException e) {
      rollback(tx);
      handleException(e);
    } finally {
View Full Code Here

      f.setFlagee(person);
      f.setFlagger(ISISession.get().getUser());
      if (period != null)
        f.setPeriod(period);
      f.setTimestamp(new Date());
      session.save(f);
      note = "on";
    } else { // Delete Flag
      session.delete(f);
      note = "off";
    }
View Full Code Here

  protected Id save(T obj) throws Exception {
    Id id = null;
    Session session = null;
    try {
      session = getSession();
      id = (Id) session.save(obj);
    } catch (HibernateException e) {
      handleException(e);
    }
    return id;
  }
View Full Code Here

          associatedObject,
          sessionImplementor
        );
    }
    catch (TransientObjectException toe) {
      id = session.save( type.getAssociatedEntityName(), associatedObject );
    }

    if ( session.contains(object) ) {
      //abort the save (the object is already saved by a circular cascade)
      return IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR;
View Full Code Here

          associatedObject,
          sessionImplementor
        );
    }
    catch (TransientObjectException toe) {
      id = session.save( type.getAssociatedEntityName(), associatedObject );
    }

    if ( session.contains(object) ) {
      //abort the save (the object is already saved by a circular cascade)
      return IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR;
View Full Code Here

        try {
            // We are not explicitly initializing a Transaction as Hibernate is expected to invoke the JTA TransactionManager
            // implicitly
            Session session = sessionFactory.openSession();
            session.save(student);
            session.flush();
            session.close();
        } catch (Exception e) {

            e.printStackTrace();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.