If I am to update serveral table in the DB. I will need to update serveral entity beans. The questions here is:
i) How to I make sure that all entity bean share the same transaction? Is it taken care by the container? Or I need to implement JTA API?
ii) What about BMP?
Thanks!
-
Transaction in CMP Entity Bean (4 messages)
- Posted by: Jimmy Tong
- Posted on: April 11 2002 14:07 EDT
Threaded Messages (4)
- Transaction in CMP Entity Bean by Daniel Lang on April 12 2002 03:01 EDT
- Transaction in CMP Entity Bean by Jimmy Tong on April 15 2002 04:58 EDT
- Transaction in CMP Entity Bean by Robert Patrick on April 17 2002 10:37 EDT
- Transaction in CMP Entity Bean by Jimmy Tong on April 15 2002 04:58 EDT
- Transaction in CMP Entity Bean by Robert Patrick on April 13 2002 11:14 EDT
-
Transaction in CMP Entity Bean[ Go to top ]
- Posted by: Daniel Lang
- Posted on: April 12 2002 03:01 EDT
- in response to Jimmy Tong
1) Remember that session beans have transactions too. So most likely you will have a session bean, which calls several different entity beans to make db changes. When you do a rollback in the session bean it can roll back all of the entiy beans. So this is no problem.
2) I'm less clear on BMP. At a guess you can still use the DB to do a rollback, but I havn't tried it out so I'm not sure.
Daniel. -
Transaction in CMP Entity Bean[ Go to top ]
- Posted by: Jimmy Tong
- Posted on: April 15 2002 04:58 EDT
- in response to Daniel Lang
Does it means that it is advisable to implement a Session bean facade to encapsulate the entity bean? Am I rite to say that if I update serveral tables in a session bean method say updateRecord(), if half way thru the updating, an sqlException is thrown, all the record and action will be rollback?
If I don't want to use a session facade, is there a way out?
Thanks for the advice. -
Transaction in CMP Entity Bean[ Go to top ]
- Posted by: Robert Patrick
- Posted on: April 17 2002 22:37 EDT
- in response to Jimmy Tong
If you use a Session Bean with the right transaction attributes, then all the call to different entity beans (assuming their transaction attributes are set properly) will be atomic (all or nothing). If you don't want to use a Session Bean facade, then you would need to use the javax.jta.UserTransaction API to demarcate your transaction. -
Transaction in CMP Entity Bean[ Go to top ]
- Posted by: Robert Patrick
- Posted on: April 13 2002 11:14 EDT
- in response to Jimmy Tong
i) How to I make sure that all entity bean share the same
> transaction? Is it taken care by the container? Or I need
> to implement JTA API?
This completely depends on the context from which you invoke the EJBs that need to share the transaction. If, as Daniel points out, you have a Session Bean method that makes the calls to the different Entity Beans and that Session Bean method is being invoked in a transactional context, then it will happen automatically as long as you make sure that the transactional attribute of all the beans are set properly.
> ii) What about BMP?
BMP is completely orthogonal to container-managed transactions. As long as you have correctly configured your BMP beans to get their database connections from a JTA aware mechanism (e.g., in WebLogic, you just set up a TxDataSource in the Server Console and have your entity beans look up and use this DataSource in their code), then both BMP and CMP beans can participate in container-managed transactions.
Hope this helps,
Robert