-->
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: why does it delete/insert when i load object
PostPosted: Fri Oct 22, 2004 10:46 pm 
Newbie

Joined: Tue Sep 14, 2004 8:59 am
Posts: 5
i have a query that gets the user who have a specific book in their bookshelf but im not sure i understand why this takes place every time i load a user.... could someone explain why?

Hibernate: select user0_.user_id as user_id,.......
Hibernate: select booklines0_.user_id ....

Hibernate: delete from BOOK_LINES where user_id=? and isbn=? and date=? and available=?

Hibernate: insert into BOOK_LINES (user_id, isbn, date, available) values (?, ?, ?, ?)


the query
session.find("select u from User u inner join u.bookshelf.booklines bl inner join bl.book b where b.isbn='"+isbn+"'");

Hibernate version:latest

Mapping documents:
<hibernate-mapping package="dk.bytenbog.model.businessobject">
<class name="User" table="USER">

<id name="username" type="string" column="user_id">
<generator class="assigned"/>
</id>

<property name="password" type="string" column="password"/>
....
....

<component name="bookshelf" class="Bookshelf">

<set name="booklines" table="BOOK_LINES" cascade="all" lazy="true">
<key column="user_id"/>

<composite-element class="Bookline">
<many-to-one name="book" class="Book">
<column name="isbn"/>
</many-to-one>

<property name="date" type="date" column="date"/>
....

</composite-element>
</set>

</component>
</class>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 23, 2004 10:06 am 
Newbie

Joined: Tue Sep 14, 2004 8:59 am
Posts: 5
i guess it had something to do with not implementing equals and hashCode right


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.