-->
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: Issue with One-to-many mapping and composite key
PostPosted: Fri Sep 19, 2008 1:19 pm 
Newbie

Joined: Fri Sep 19, 2008 1:09 pm
Posts: 1
I have some issue with the One-to-many mapping and composite key.

I have a table PropT - Parent

column prop_nbr (PK)

Table PropRoleUserT - Child

Composite PK ( prop_nbr , role_nm)

This has a FK for prop_nbr with PropT.prop_nbr

In both the table prop_nbr is not null.

The issue is when I update a data in both parent and child , it is updating the parent , but it is also updating the child for prop_nbr as null and getting the Not null exception. I am not sure why is it updating the prop_nbr in PropRoleUserT to null when I am sending the data.

I want an immediate help.

I am using the XML mapping from Hibernate 3.0 and not POJO.

Here are my mappings :

PROPT
----------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class entity-name="PropT" table="PROP_T" schema="SYSTEM">
<id name="propNbr" type="long" column="PROP_NBR" length="19">
<generator class="sequence">
<param name="sequence">PROP_T_SEQ</param>
</generator>
</id>
<property name="bpmProcessId" type="string"
column="BPM_PROCESS_ID" length="100" />
<property name="dueDt" type="date" column="DUE_DT" length="7" />
<property name="prodDescr" type="string" column="PROD_DESCR"
length="255" />
<property name="propDescr" type="string" column="PROP_DESCR"
length="255" />
<property name="recipientNm" type="string" column="RECIPIENT_NM"
length="100" />
<property name="recvdDt" type="date" column="RECVD_DT"
length="7" />
<property name="senderNm" type="string" column="SENDER_NM"
length="255" />

<!-- Associations -->
<!-- bi-directional many-to-one association to PropNotificationT -->
<set name="propNotificationTs" inverse="false" lazy="true">
<key>
<column name="PROP_NBR" /><!-- a foreign key in PROP_NOTIFICATION_T referencing the primary key of this table. -->
</key>
<one-to-many entity-name="PropNotificationT" />
</set>
<!-- bi-directional many-to-one association to PropRoleUserT -->
<set name="propRoleUserTs" inverse="false" lazy="true">
<key>
<column name="PROP_NBR" /><!-- a foreign key in PROP_ROLE_USER_T referencing the primary key of this table. -->
</key>
<one-to-many entity-name="PropRoleUserT" />
</set>
<!-- bi-directional many-to-one association to StatTypT -->
<many-to-one name="statTypT" class="StatTypT" lazy="proxy">
<column name="STAT_TYP_NBR" not-null="true" length="22" />
</many-to-one>

</class>
<query name="get.proposal.data.by.proposalId">
<![CDATA[
from PropT as prop where prop.propNbr = :proposal_id]]>
</query>
</hibernate-mapping>

PropRoleUserT
-------------------------


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class
entity-name="PropRoleUserT"
table="PROP_ROLE_USER_T"
schema="SYSTEM"
>
<composite-id>
<key-property
name="activeDirNm"
type="string"
column="ACTIVE_DIR_NM"
length="30"
/>
<key-property
name="propNbr"
type="integer"
column="PROP_NBR"
length="7"
/>
<key-property
name="roleNm"
type="string"
column="ROLE_NM"
length="50"
/>
</composite-id>

<!-- Associations -->
<!-- bi-directional many-to-one association to PropT -->
<!-- many-to-one
name="propT"
class="PropT"
update="false"
insert="false"
lazy="proxy"
>
<column name="PROP_NBR" not-null="true" length="7"/>
</many-to-one //-->

</class>
</hibernate-mapping>


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.