If I have BeanHome1 and BeanHome2, is there any way that
control the transaction that either these I create the two entity beans or none of them.
// start transaction
Of course - create these two beans from a session facade. Configure the transaction attributes of the entities so that the creation is done under the transaction context of the session bean. The transaction attribute of the session bean needs to be set to Required or RequiresNew; both entitie must have their transaction attribute to mandatory.
Well, I guess Oracle Application Server 9.0.2 may have a serious bug on this. I did try to do this( I tried required, requiresnew and mandatory in the xml description.
) howerver the first bean creation was not rolled back when the second bean creation had an exception ( I intendly put a larger string to a column with varchar2(20)). I tried the user transaction with
ut = getUserTransaction
with the same data, it DID WORK. The rolling back was done properly.
Well, what kind of exception was passed to the container? Application exceptions do not automatically trigger rollbacks, only system exceptions do. Try catching the SQLException, and throwing an EJBException (which is a system exception). If you are throwing an EJBException with CMT and you don't get a rollback, there's something seriously messed up.
Try to delay the insert till end of transaction by using the delay-updates-until-end-of-tx deployment descriptor element. This element is set in the weblogic-ejb-jar.xml file. When you set this element to "true," WebLogic Server calls ejbStore() after the conclusion of the transaction.