• 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

'EJB3 in action' - needs of clarification about BMT (Bean Managed Transaction)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
H all,

this comes from the EJB3 in action book :

Another drawback for BMT is the fact that it can never join an existing transaction.



I would like to be sure I'm getting this right with your help if you do not mind too much.

I want to have full control of any transaction which made me interested in BMT.

Everything works and now I want to develop some more sophisticated code using BMT. However I would hate having methods of hundreds of line.
Here What I would like to do : have a main service (let's call it MS) with a method opening a transaction, calling other methods services (let's call them s1, s2) and then commit.

As long I only use methods of others services that only execute Data reading (find* methods), I'm fine.

But If I want to have methods modifying data, I would get the sadly famous javax.persistence.TransactionRequiredException: EntityManager must be access within a transaction.

what I am trying to do looks like this :



So far, the only way I have is to have the code of each method of each sub service inside my method from MS. that makes it super long which I find is ridiculous...

any idea? how to do differently?
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alfred,

If I understand this correctly, you really can't do this via BMT. The nested service calls would need to be CMT. The reason a BMT "join" is not allowed is because it can open the container up-to some very serious bugs/inconsistencies.

Regards,
Reza
 
Alfred Couder
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you Reza!
 
Nothing? Or something? Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic