-->
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: Bidirectional Association one-to-many generate Extra query
PostPosted: Sun Nov 21, 2010 2:15 am 
Newbie

Joined: Sat Feb 13, 2010 1:04 pm
Posts: 10
Mapping file:


<hibernate-mapping package="com.sample">
<class name="Parent" table="parent">
<id name="id" column="PARENT_ID">
<generator class="native"/>
</id>

<property name="name" column="PARENT_NAME"/>
<set name="childList" cascade="all" inverse="true">
<key>
<column name="PARENT_ID"/>
</key>
<one-to-many class="Child"/>
</set>
</class>

<class name="Child" table="child">
<id name="id" column="CHILD_ID">
<generator class="native"/>
</id>

<property name="name" column="CHILD_NAME"/>
<many-to-one name="parent" class="Parent" column="PARENT_ID"
not-null="false" cascade="all"/>
</class>
</hibernate-mapping>


Generated Queries by Hibernate :

Hibernate: insert into parent (PARENT_NAME) values (?)
Hibernate: insert into child (CHILD_NAME, PARENT_ID) values (?, ?)
Hibernate: insert into parent (PARENT_NAME) values (?)
Hibernate: insert into child (CHILD_NAME, PARENT_ID) values (?, ?)

hibernate generates extra insert query for parent table.

can anyone say me what i am doing worng in 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.