Hi, 

I am using JBoss 4.0.5GA and mysql 5.0 database. 


in web tier: 

UserTransaction userTransaction = 
  | (UserTransaction)new InitialContext().lookup("java:comp/UserTransaction"); 
  | 
  | userTransaction.begin(); 
  | 
  | 
  | // in session bean, em is EntityManager 
  | em.persist(entity); 
>From mysql console, the entity was created immediately in database(mysql). 

I expected it to be created after calling 

userTransaction.commit(); 
in web tier. 


For debugging, I added the following code around em.persist(entity): 

//debug 
  | Session session = ((HibernateSession)em).getHibernateSession(); 
  | Transaction t = session.getTransaction(); 
  | 
  | t.begin(); 
  | 
  | em.persist(entity); // the enitty was created immediately in database (see 
from mysql console) 
  | 
  | t.rollback(); 
  | 
  | boolean committed = t.wasCommitted(); // value is false 
  | boolean rollback = t.wasRolledBack(); // value is false 
after the rollback, the created entity did not roll back. The transaction was 
ignored. 

Is this a bug? How to use UserTransaction with entityManager? 

Thanks for any help! 
Dave

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134541#4134541

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134541
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to