Package org.hibernate

Examples of org.hibernate.Session.save()


        student.setLastName(lastName);

        try {
            Session session = sessionFactory.openSession();
            Transaction trans = session.beginTransaction();
            session.save(student);
            session.flush();
            trans.commit();
            session.close();
        } catch (Exception e) {
View Full Code Here


        try {
            Session session = sessionFactory.openSession();
            Transaction trans = session.beginTransaction();
            student = (StudentAudited) session.load(StudentAudited.class, id);
            student.setAddress(address);
            session.save(student);
            session.flush();
            trans.commit();
            session.close();

        } catch (Exception e) {
View Full Code Here

        student.setLastName(lastName);

        try {
            Session session = sessionFactory.openSession();
            //Transaction trans = session.beginTransaction();
            session.save(student);
            session.flush();
            //trans.commit();
            session.close();
        } catch (Exception e) {
View Full Code Here

        student.setLastName(lastName);
        Session session = sessionFactory.openSession();

        try {
            Transaction trans = session.beginTransaction();
            session.save(student);
            trans.commit();
        } catch (Exception e) {

            e.printStackTrace();
            throw new RuntimeException("transactional failure while persisting student entity", e);
View Full Code Here

        student.setAddress(address);

        try {
            // invoking the Hibernate transaction
            Transaction trans = session.beginTransaction();
            session.save(student);
            trans.commit();
        } catch (Exception e) {

            e.printStackTrace();
            throw new RuntimeException("transactional failure while persisting student entity", e);
View Full Code Here

    javax.transaction.Transaction tx = txm.getTransaction();
    System.out.println(tx);
    try {
      Session session = getSession();
      System.out.println(session.getTransaction());
      id = (Id) session.save(obj);
    } catch (HibernateException e) {
      handleException(e);
    }
    return id;
  }
View Full Code Here

     */
    public void saveRule(Rule rule, RuleChange change) {
        Session session1 = getHibernateTemplate().getSessionFactory().openSession();
        Transaction tx = session1.beginTransaction();
        session1.saveOrUpdate(rule);
        session1.save(change);
        tx.commit();
        session1.close();
    }
   
    public void saveChange(RuleChange change) {
View Full Code Here

   }

   public Object create(Object obj) throws Exception
   {
      Session session = openSession();
      session.save(obj);
      session.flush();
      return obj;
   }

   public Object update(Object obj) throws Exception
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

  //保存对象 ,返回一个boolean 来判断状态
  public static boolean save(Object object){
    Session sessions = HibernateUtil.getSession();
    Transaction transaction = sessions.beginTransaction();
    try {
      sessions.save(object);
      transaction.commit();
      return true;
    } catch (HibernateException e) {
      // TODO Auto-generated catch block
      if(transaction!=null)
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.