-->
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.  [ 1 post ] 
Author Message
 Post subject: One to Many Problem
PostPosted: Fri Jul 15, 2005 12:56 am 
Newbie

Joined: Fri Jul 15, 2005 12:42 am
Posts: 18
I'm facing a problem in one to many mapping in Hibernate 3!Hope somebody can help me!!

Consider this One to many Mapping
Participant.hbm.xml
<set
name="participantTypes"
table="ParticipantParticipantType"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>

<key
column="PARTICIPANTID"
>
</key>

<one-to-many
class="ParticipantParticipantTypeDTO"
/>

</set>
######
Participant Fields- PARTICIPANTID,Name
ParticipantParticipantType fields -ID,PARTICIPANTID,PARTICIPANTTYPEID
#######
When I try to Add a new Participant (with inverse=true) with a set of
ParticipantParticipantTypes; Participant is being added properly with
PARTICIPANTID say a 200 (System generated ) .But entry in
ParticipantParticipantType table has PARTICIPANTID 0 not 200 .When i
give "inverse=false" It is working properly!!

But now its giving a new problem..!!Suppose I want to remove a
ParticipantParticipantType i deleted it from the set but its showing
exception given below

####################
org.hibernate.exception.ConstraintViolationException: could not delete
collection rows:
[com.security.dto.ParticipantDTO.participantTypes#1090]
at.....

Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT]
SQL0407N Assignment of a NULL value to a NOT NULL column
"TBSPACEID=2, TABLEID=51, COLNO=1" is not allowed. SQLSTATE=23502

at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.collection.AbstractCollectionPersister.deleteRows(AbstractCollectionPersister.java:961)

#######################



The irony is that if I give "inverse=true" This will
happen Perfectly!


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

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.