• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMT doesn't commit DB changes in a POJO

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the code flow : Session Bean --> Pojo( working on JPA entities) --> DB.
As the POJO class is doing the JPA writes, I have configured it to resource_local and using entitymanagerFactory to get entitymanager and entitymanager.gettransaction to begin and commit transactions.
In one of the scenarios, the Session bean calls one of the methods of the Pojo where it has to remove some entities. Bean's method is already in a container managed transaction so, if I try to begin or commit the entitymanager.gettransaction in Pojo's method it throws exception. Fair enough as I am not allowed to call commit in a CMT but if I do not use the entitymanager.gettransaction, the JPA updations don't reflect in DB when the CMT is commited.

Update: I assume the reason CMT is not updating the DB is because we close the entityManager before getting out of the method in the POJO. I tried annotating the method with TransactionAttributeType.NOT_SUPPORTED so that I can use entityManager.getTransaction inside but it still behaves like it's still getting called in the CMT.

Any Insight would be really appreciated.

Thanks
 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Teddy Westside", please check your private messages regarding an important administrative matter.
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic