File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes EJB3 (JBoss 5) Problem with Persistence Context / Transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB3 (JBoss 5) Problem with Persistence Context / Transaction " Watch "EJB3 (JBoss 5) Problem with Persistence Context / Transaction " New topic
Author

EJB3 (JBoss 5) Problem with Persistence Context / Transaction

Markus Schmider
Ranch Hand

Joined: Feb 25, 2007
Posts: 86
I am experimentig with JPA and I have difficulties to reproduce an example taken from JavaMagazin 9/09 about the ECB Pattern.
JBoss 5.1.0 GA, MySQL 5.0



The "boundary" (facade)





The Warehouse Bean persists the order. This works like expected:




However the DeliveryService modifies the order:




Since the transaction should be still running, I expect that order is still in the persistence context and that the changes made by the DeliveryService should be automatically persisted. However they never arrive in the database.

Do I get the whole concept or persistence context wrong? Or is there some bug in my code?






Christian Gossart
Ranch Hand

Joined: Mar 13, 2008
Posts: 34
Hi Marcus,

Seems the checkout method is bugged if you are using it with a brand new Order instance: when using the merge method of the EntityManager with a new entity instance, this instance remained detached while a new managed instance is created and stored in the persistence context. It is this managed instance that is returned from the merge call. To get a hold on it, use the following code instead:



Then the Order instance returned from the checkout method is managed, and any change done by the deliver method will produce an sql update when the transaction commits.

Christian Gossart
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3 (JBoss 5) Problem with Persistence Context / Transaction
 
Similar Threads
Name Not Bound Exception
JPA,/mysql/JBoss and a big head ache
Throw an exception dosnt cause to rollback when it is not
problem in setting mySql as default database server
Error while starting jboss(java.lang.ClassNotFoundException: No ClassLoaders found for: com.mysql.j)