An app I'm working on is using Oracle and Hibernate as ORM. When I'm trying to insert PartyUserObject I keep getting following errors:
Code:
could not insert: [Person]; SQL [insert into PARTY (............)]; constraint [PARTY_FK1]
java.sql.SQLIntegrityConstraintViolationException: ORA-02291: integrity constraint (PARTY_FK1) violated - parent key not found
The message seems to be obvious, but I can't configure Hibernate to get it working. Relevant entities' relations and hbm.xml files are as follows:
PartyUser.java
Code:
private Party ap;
Party.java
Code:
private Address address;
private Set<PartyUser> partyUsers;
PartyUser.hbm.xml
Code:
<many-to-one
name="ap"
column="AP_ID"
class="Party"
not-null="true"
lazy="false"
cascade="save-update,evict">
</many-to-one>
Party.hbm.xml
Code:
<set name="partyUsers" inverse="true" fetch="subselect">
<key column="AP_ID"/>
<one-to-many class="PartyUser"/>
</set>
PARTY_FK1 refers to address FK in the party table. As I said before save is called on the DAO for a newly instantiated PartyUser object (associated Party and Address objects are new as well). All ids are generated on the java side. As you probably noticed both entities has cascade turned on.
Any ideas what's wrong?