1 Reply Latest reply on Sep 12, 2002 1:32 PM by Dain Sundstrom

    ejbPostCreate deferred?

    Hans-Peter Keck Newbie


      I would like to clarify my understanding of the ejbCreate/ejbPostCreate execution. If several entity beans of the same type are created in one transaction, is it allowed for the Container to execute all the ejbCreate methods first and defer the execution of ejbPostCreate to a later time? It seems that JBoss is doing that.

      I noticed this behaviour using beans in a one-many relationship. For the beans on the many side, I have a unique constaint set in the database table that includes the foreign key. When creating several of those beans in one transaction, the database gives me a unique constaint violation error. This happens because the foreign key is only set in ejbPostCreate, but the database entries are already created after ejbCreate has been executed (and the foreign key is still NULL). It seems that all of the beans are first created, and the setting of the foreign key (in ejbPostCreate) is deferred until later.

      Is this a bug or a feature?