-->
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: Need help with sql-update
PostPosted: Thu Aug 26, 2010 3:02 pm 
Newbie

Joined: Sun Apr 18, 2010 11:56 pm
Posts: 5
After reviewing the documentation, I cannot see how to use sql-update in a realistic case.
Given:
public class Person {
private Long id; // identifier
private String name;
private String address;
private Date phone;
private Person bestfriend;
...
}
and hibernate-mapping
<class name="Person"
table="person"
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="address"/>
<property name="phone" />
<many-to-one name="bestfriend" column="bf" class="Person" />
...
</class>

What would be the signature for sql-update ? - especially if the person instance representing bestfriend can be deleted ?

When trying this in various scenarios I find that upon issuing the session.delete(aPerson), I see Hibernate trying to issue sql updates such as
update person set bf=null where bf={deleted Person id}
and when updating the person address I see:
update person set name='Jane', address='123 main st', phone='123-4567', bf=789 where id=3

From the above it seems that there are at least two different signatures for sql-update needed.

DB is mysql, Hibernate version 3.3.2


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.