2 Replies Latest reply on Aug 23, 2005 4:34 PM by Evan Nail

    FK- Insert and PostEJBCreate

    Evan Nail Newbie

      I have a couple of CMP EBs involved in a CMR and am having problems with the create.

      For example. ( I'll change the real object to make it easier to understand)

      An auction is created with an owner. The owner_id in the auction table is a fk and it is not null. In other wors you must do the insert knowing the owner.

      I've set all the realtionships up and it looks like several other examples I've seen. In my create for auction i set its values from a vo and pass the ownerLocal to the create. In the postcreate I set the owner for the new auction bean. I cant set the owner before because the spec wont allow me to call a cmr field in the create.

      Problem is that since the fk is not null in the database, it looks like the insert is attempted then the post create called. This would work if my fk was nullable as I assume I'd then get an update with the fk in postcreate. However my fk is not null so i get the can insert null sql error on the create.

      In WL and maybe some other containers you could tell the insert to wait until postcreate to do the insert and I think thats how I have gotten around this issue before.

      Is that possible with jboss?

      OR is my problem entirely something else? Can you do the fk insert in the create?



        • 1. Re: FK- Insert and PostEJBCreate
          Evan Nail Newbie

          OK It looks like there is a container configuration setting for the jboss.xml that will do the inserts on post creates.

          mmmm...now to figure out how to do it with xdoclet?

          anyone have an example?

          • 2. Re: FK- Insert and PostEJBCreate
            Evan Nail Newbie

            OK, just to close this out...
            This configuration setting should do it.

             <container-configurations>
             <container-configuration extends="Standard CMP 2.x EntityBean">
             <container-name>INSERT after ejbPostCreate Container</container-name>
             <insert-after-ejb-post-create>true</insert-after-ejb-post-create>
             </container-configuration>
             </container-configurations>
            


            I added this to my merge directory in xdoclet and it gets included in the jboss.xml

            I didnt have much luck though with the redeploy so i changed the base configurations settings in the jboss.xml in the conf directory directly undeployed, cycled etc and now it seems to wait until after the post to do the insert.