Reputation: 2132
I have an EJB, whose method (among other things) load an entity and modify it. If the method completes then modifications of that entity automatically committed to database without calling EntityManager.saveOrUpdate() method? And when the method fails then the transaction of that EJB method will be rolledback along with the modifications of that entity?
Upvotes: 0
Views: 124
Reputation: 1530
With EJB implicitly your method is bound with a transaction. If you load the entity with the entity manager, the entity is attached with the persistent context, so if you do modifications on the object, upon transaction end, if all goes right the transaction commits and the modifications are flushed to the database, otherwise if some error happens the transaction rolls back, and the modifications are discarded.
Upvotes: 1