-->
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: Hibernate is running updates/deletes during a load operation
PostPosted: Tue Apr 11, 2006 7:00 pm 
Newbie

Joined: Wed Apr 05, 2006 5:58 pm
Posts: 13
Hibernate version: 3.1

Mapping documents:
<hibernate-mapping>
<class name="User" table="user">
<id name="id" column="user_id">
<generator class="Generator">
<param name="sequence_name">main_sequence</param>
</generator>
</id>
<property name="firstName" column="first_name"/>
....
<set name="emailAddresses" cascade="none">
<key column="user_id"/>
<one-to-many class="com.topcoder.web.reg.model.Email"/>
</set>
<joined-subclass name="BusinessUser" table="buser">
<key column="buser_id"/>
<property name="company"/>
</joined-subclass>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="Email" table="email">
<id name="id" column="email_id">
<generator class="Generator">
<param name="sequence_name">EMAIL_SEQ</param>
</generator>
</id>
<property name="userId" column="user_id" access="field"/>
<property name="emailTypeId" column="email_type_id" access="field"/>
<property name="address" access="field"/>
<property name="primary" type="boolean" column="primary_ind" access="field"/>
<property name="statusId" column="status_id" access="field"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
session.load(BusinessUser.class, id);

Name and version of the database you are using:
Informix 10.x

The generated SQL (show_sql=true):
Hibernate: select buser0_.buser_id as user1_9_0_, buser0_1_.first_name as first2_9_0_, buser0_1_.middle_name as middle3_9_0_, buser0_1_.last_name as last4_9_0_, buser0_1_.handle as handle9_0_, buser0_1_.status as status9_0_, buser0_1_.password as password9_0_, buser0_1_.activation_code as activation8_9_0_, buser0_.member_since as member2_12_0_, buser0_.quote as quote12_0_, buser0_.buser_type_id as buser4_12_0_, buser0_.comp_country_code as comp5_12_0_ from buser buser0_ inner join user buser0_1_ on buser0_.buser_id=buser0_1_.user_id where buser0_.buser_id=?
Hibernate: select emailaddre0_.user_id as user2_1_, emailaddre0_.email_id as email1_1_, emailaddre0_.email_id as email1_3_0_, emailaddre0_.user_id as user2_3_0_, emailaddre0_.email_type_id as email3_3_0_, emailaddre0_.address as address3_0_, emailaddre0_.primary_ind as primary5_3_0_, emailaddre0_.status_id as status6_3_0_ from email emailaddre0_ where emailaddre0_.user_id=?
Hibernate: update email set user_id=null where user_id=?
Hibernate: update email set user_id=? where email_id=?

This question I have is, why is hibernate performing those two updates on the email table? If I load the parent class (User), this does not happen. The data is loaded and there are no odd updates, however if I load the child class, this is what I get.

Any idea why?

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.