I use JBoss 4.0.5 GA. JSF web application
create a thread local userTransaction
userTransaction.begin() // in JSF before invoke application phase
em.persist(entity1) //create entity in session bean using entity manager
do something that throw exception
cought the exception and indicate the transaction need to rollback
userTransaction.rollback() // in JSF after invoke application phase
but entity1 is created in database.
I debugged the code, the rollback was called.
Thanks for help.
Does your database support transactions? MySQL MyISAM tables for example don't and you would see that kind of behavior. Use InnoDB instead (or any other transaction-capable DB).