-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: integrity contraint violated - parent key not found
PostPosted: Wed Aug 15, 2012 2:44 pm 
Newbie

Joined: Wed Aug 15, 2012 2:39 pm
Posts: 2
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?


Top
 Profile  
 
 Post subject: Re: integrity contraint violated - parent key not found
PostPosted: Thu Aug 16, 2012 4:26 am 
Newbie

Joined: Wed Aug 15, 2012 2:39 pm
Posts: 2
FYI, it turned out that java own key generation did all the mess.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.