-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cascade saving foreign key problem
PostPosted: Mon Jul 02, 2007 8:30 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Hi,

I have an entity "user" that consists of an entity "confidentiallevel". When saving a "user" with a new "confidentiallevel" it should persist everything. The mappings have the cascade="save-update" option.

sessionFactory.getCurrentSession().saveOrUpdate(userEntity);

I get an exception saying "ORA-02291:, integrity constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) violated - parent key not found":

Code:
Hibernate: select USERS_ID_SEQ.nextval from dual
Hibernate: select CONFIDENTIALLEVEL_ID_SEQ.nextval from dual
Hibernate: insert into MYSCHEMA.CONFIDENTIALLEVEL (CONFLEVEL, ACTIVATED, ACTIVATIONCHANGE, ID) values (?, ?, ?, ?)
Hibernate: insert into MYSCHEMA.USERS (CONFIDENTIALLEVEL, NAME, PASSWORD, EMAIL, ACTIVATED, ACTIVATIONCHANGE, ID) values (?, ?, ?, ?, ?, ?, ?)
2007-07-02 14:23:44,723 [http-8080-1] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 2291, SQLState: 23000
2007-07-02 14:23:44,723 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02291: Integritäts-Constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) verletzt - übergeordneter Schlüssel nicht gefunden

2007-07-02 14:23:44,723 [http-8080-1] WARN  org.hibernate.util.JDBCExceptionReporter - SQL Error: 2291, SQLState: 23000
2007-07-02 14:23:44,723 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02291: Integritäts-Constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) verletzt - übergeordneter Schlüssel nicht gefunden

2007-07-02 14:23:44,823 [http-8080-1] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) .....................


It seems as if the confidentiallevel entity isn't saved and so there occurs a foreign key violation.

What to do please?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 3:20 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Nobody any idea?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 13, 2007 5:10 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Found: I forgot to edit the Users Cascade option in the related hbm.xml file. Now it works!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.