0 Replies Latest reply on Dec 18, 2009 5:49 AM by Patrick Jusseau

    Not null foreign key with master-detail

    Patrick Jusseau Newbie

      Hi,

       

      I have a new master-detail entities graph object that I want to persist using HIbernate as the JPA provider. So in my DETAIL table I have a foreign key that references the Master primary key. This foreign key is marked as NON NULL in my Oracle 10g database to ensure data integrity. However each time I try to persist my master and detail objects I got the following error :

       

      11:02:37,179 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: org.hibernate.PropertyValueException: not-null property references a null or transient value: com.jcom.common.entity.history.Detail._detailEntitiesBackref

       

      The only way I found to avoid this error is to change the nullable state in of the foreign key to accept NULL values which breaks the data integrity since the foreign should never be null in my case.

       

      What do I need to do to keep the NOT NULL foreign key constraint ???

       

      Thanks for any help,

      - Patrick