If my session bean with single method insert record into 2 entity beans, how can know that the process is done in same transaction (the attributes for these beans are Required)?
If your session bean is using bean-managed transactions, you can ensure that the calls are handled in the same transaction by : javax.transaction.UserTransaction tran= null; try{ tran=ctx.getUserTransaction(); tran.begin(); myBeanHome1.create(….); myBeanHome2.create(…); tran.commit(); }catch(…){} You may want to check if you’re already running in a transaction by calling tran.getStatus().
Related Questions
- If I throw a custom ApplicationException from a business method in Entity bean which is participating in a transaction, would the transaction be rolled back by container?
- My session beans call other bean methods within a transaction. Using bean-managed transactions, how should I take care of commit and rollback ?
- If using: - session beans - entity bean with BMP - entity beans with CMP?