-->
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: Question on hibernate internals
PostPosted: Fri Mar 26, 2004 3:10 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
Hello,

I have a collection and modifications to the collections work in sync with the table. But this is only when I remove the unique and not null constraints on the association table(Association table has a reference to a parent object that is not null at the time of execution). After I add the constraints again the console starts showing the exceptions. Can anyone throw some light on this ? how is it internally executed ?

What I can conclude from this is first an update is fired to database for the changes and then the records are deleted. Hibernate is smart enough to track all this. Is there any other way out other than removing the constraint ?

Exception I get with null constraint :
Hibernate: update STS.METADATA_SUBJECT_APHASIA set SUBJECT_ID=null where SUBJECT_ID=? and ID=?
WARN [http8080-Processor2] JDBCExceptionReporter.logExceptions(38) | SQL Error: 1407, SQLState: 72000
ERROR [http8080-Processor2] JDBCExceptionReporter.logExceptions(46) | ORA-01407: cannot update ("STS"."METADATA_SUBJECT_APHASI
A"."SUBJECT_ID") to NULL

nitin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 3:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a FAQ. Please read "parent child relationship" doc.


Top
 Profile  
 
 Post subject: Not working for me
PostPosted: Fri Mar 26, 2004 8:31 am 
Beginner
Beginner

Joined: Wed Mar 17, 2004 12:44 am
Posts: 25
Thanx gavin,

I did change the mappings but still not working for me. The insert query is giving me an exception. Can I see the values somehow that it is trying to insert ?

Parent :
<set name="aphasiaTypes" inverse="true" cascade="all-delete-orphan" >
<key column="SUBJECT_ID"/>
<one-to-many class="com.imc.sts.domain.the.SubjectAphasia" />
</set>

Child :
<many-to-one name="parentSubject" class="com.imc.sts.domain.the.Subject" column="SUBJECT_ID" not-null="true" />

Exception :
Hibernate: insert into STS.METADATA_SUBJECT_APHASIA (TIMESTAMP, SUBJECT_ID, APHASIA_ID, ID) values (?, ?, ?, ?)
WARN [http8080-Processor2] JDBCExceptionReporter.logExceptions(38) | SQL Error: 1, SQLState: 23000
ERROR [http8080-Processor2] JDBCExceptionReporter.logExceptions(46) | ORA-00001: unique constraint (STS.SYS_C002207) violated

WARN [http8080-Processor2] JDBCExceptionReporter.logExceptions(38) | SQL Error: 1, SQLState: 23000
ERROR [http8080-Processor2] JDBCExceptionReporter.logExceptions(46) | ORA-00001: unique constraint (STS.SYS_C002207) violated

ERROR [http8080-Processor2] JDBCException.<init>(38) | Could not execute JDBC batch update
java.sql.SQLException: ORA-00001: unique constraint (STS.SYS_C002207) violated

Constraints :
- AphasiaId not null
- SubjectId not null
- Unique constraint on combination of AphasiaId and SubjectId
- Referential Integrity for AphasiaId and SubjectId,
- ID Primary key



nitin


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.