• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Alfred Couder
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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?
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Ok, thank you Reza!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!