when I'm creating an Entity Bean inside the ejbPostCreate of another Entity Bean, how do I tell the application server that these two creation steps are part of one transaction, i.e. the creation of the Bean the ejbPostCreate belongs to has to be rolled back if the creation of the second bean fails?
Have a session facade with "new transaction" call your entity beans with "transaction required". Both create will occur in the same transaction...
Session Facade (Required) --> Entity 1 (Mandatory)
Entity 2 (Mandatory)
Problem with constraint in database.
The WebLogic 7.0 app server´s dbms configuration descriptor has a tag
<delay-database-insert-until> which defines the stage in an entity bean´s
create process in which the bean is persisted in the database.
The allowed values are: ejbPostCreate(default), ejbCreate and commit
This is useful when we need to create a child entity from inside the
ejbPostCreate method of a parent entity. The foreign-key field on the
child´s table will try to match an existing key on the parent, but since it
has not been persisted, a violation error will occur. To avoid that, and
still use the foreign-key constraint in the child´s table, we use the
"ejbCreate" or "commit" value on the tag in the parent bean´s descriptor.
In JBOSS, for example this is not possible.
Alvaro Mota Goncalves