-->
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: id not cascading to relation
PostPosted: Wed May 05, 2010 1:13 am 
Newbie

Joined: Tue May 04, 2010 3:06 pm
Posts: 3
Hi

i've two tables..
table1 has primary key [id_1]
table2 has foreign key [id_1] and a composite primary key [id_1, id2]

when using hibernate save() on table1, the id_1 generated {using increment strategy} isn't cascading to table2 and i am getting a null exception.

here are mappings i've used in code:

table1

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

<hibernate-mapping>
<class name="classA" table="TABLE1">
<id name="Id" column="ID" type="java.math.BigInteger">
<generator class="sequence">
<param name="sequence">seqGen</param>
</generator>
</id>

<property name="anyText" column="SOME_TEXT" type="string"/>

<bag name="ClassB" inverse="true" cascade="all" >
<key column="ID"/>
<one-to-many class="ClassB"/>
</bag>


</class>
</hibernate-mapping>



table2

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

<hibernate-mapping>
<class name="ClassB" table="TABLE2">
<composite-id >
<key-property name="Id" access="field" column="ID"/>
<key-property name="Id2" access="field" column="ID2" />
</composite-id>
</class>
</hibernate-mapping>


what could be the problem with this?...am using DB2..
much thanks!!


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.