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?