Package org.hibernate

Examples of org.hibernate.Transaction.commit()


    if(transactions == null)
      return;
    // Would be written as a no-op in an EJB container with CMT
    Transaction tx = (Transaction)transactions.get();
    if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) {
      tx.commit();
    }
    else{
      if(tx!=null && log.isWarnEnabled())
        log.warn("Trying to commit the uncommitable transaction, nothing to do.");
    }
View Full Code Here


      System.out.println("============== Bookmarks upgraded.=================");
     
      upgradeMessages(old_ssn, new_ssn);
      System.out.println("============== Messages upgraded.=================");
     
      tx.commit();
      System.out.println("============== DLOG4J upgraded.=================");
    }catch(Exception e){
      e.printStackTrace();
      tx.rollback();
    }finally{
View Full Code Here

      return action.execute(method, parameters);
    else {
      Transaction tx = session.beginTransaction();
      try {
        Object result = action.execute(method, parameters);
        tx.commit();
        return result;
      } catch (Exception e) {
        tx.rollback();
        throw e.getCause();
      }
View Full Code Here

    try {
      //执行被拦截的业务方法
      result = methodInvocation.proceed();
      //提交事务
      if(type != TransactionalType.READOLNY){
        transaction.commit();
      }
    } catch (Exception e) {
      //回滚当前事务
      if(type != TransactionalType.READOLNY && transaction.isActive()){
        transaction.rollback();
View Full Code Here

        need2ProcessTransaction = session.isNeed2ProcessTransaction() && !hbTS.wasCommitted();
      }

      if(need2ProcessTransaction){
        if(hbTS != null)
          hbTS.commit();
        if(jpaTS != null)
          jpaTS.commit();
      }
    } catch (Exception e) {
      if(hbTS != null)
View Full Code Here

    princess.setId(new Integer(11));
    princess.setZip(new Integer(00001));
    princess.setName("shrek");

    session.save(princess);
    tx.commit();
    session.getTransaction().commit();

    HibernateHelper.closeSession();

    System.out.println("testWriteHibernate Done");
View Full Code Here

        ItemIF anItem = builder.createItem(channel, "Item: " + items, desc, new URL("http://www.sf.net"));
        anItem.setUnRead(unreadflag);
      }
      session.save(channel);
      chId = (int) channel.getId();
      tx.commit();
    }
    catch (HibernateException he) {
      logger.warn("trying to rollback the transaction");
      if (tx != null) tx.rollback();
      throw he;
View Full Code Here

   
    Transaction tx = null;
    try {
      tx = session.beginTransaction();
      session.save(catA);
      tx.commit();
      catId = new Long(catA.getId());
      System.out.println("Saved category with id " + catId + " persistently");
    }
    catch (HibernateException he) {
      if (tx != null) tx.rollback();
View Full Code Here

    session = handler.getSession();
    try {
      tx = session.beginTransaction();
      Category theCat = (Category) session.load(Category.class, catId);
      theCat.setTitle("Another category title");
      tx.commit();
      System.out.println("Updated category title for id: " + catId);
    } catch (HibernateException he) {
      if (tx != null) tx.rollback();
      throw he;
    }
View Full Code Here

      // Query q = session.createQuery("select cat.id from Category as cat");
      // List result = q.list();
      Query q = session.createQuery("from Category as cat where cat.title = :title");
      q.setParameter("title", "Another category title", Hibernate.STRING);
      List cats = q.list();
      tx.commit();
      Iterator it = cats.iterator();
      while (it.hasNext()) {
        Category c = (Category) it.next();
        System.out.println("--> " + c.getId());
      }
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.