Cascaded creation of Entity Beans


EJB design: Cascaded creation of Entity Beans

  1. Cascaded creation of Entity Beans (2 messages)

    Hi there,

    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?

  2. Cascaded creation of Entity Beans[ Go to top ]

    Have a session facade with "new transaction" call your entity beans with "transaction required". Both create will occur in the same transaction...
  3. Cascaded creation of Entity Beans[ Go to top ]


    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