-->
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.  [ 2 posts ] 
Author Message
 Post subject: Insert+Update on save of an entity with one-to-many reln
PostPosted: Thu Jun 15, 2006 3:53 am 
Newbie

Joined: Thu Jun 08, 2006 1:08 am
Posts: 1
Hibernate version: 3

Name and version of the database you are using: Oracle 10g

Tables:
Task
Task_Attribute [having Task_id as foreign key in Task table]

Java entities:
Task [having a collection of 'TaskAttributes']

When we save a TaskEntity, Hibernate is doing both 'Insert' as well as 'Update' on 'Task Attribute' table for the same record.

As we have triggers on these table, Insert and Update triggers are being called when only 'insert' should have been called.

Hibernate Mapping:
<class name="Task" table="TASK">
.....
<bag name="attributes" table="TASK_ATTRIBUTE" cascade="all" lazy="false" inverse="false">
<key column="TASK_ID" not-null="true"/>
<one-to-many class="TaskAttribute"/>
</bag>
.....
</class>

Is there a way to avoid 'insert+update' by hibernate when its just 'inserting' task attribute?

Help highly appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 5:35 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Try again with inverse="true" for 'attributes' collection.

Have a look at this:

http://www.hibernate.org/hib_docs/v3/re ... hild-bidir


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.