-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to save an object...
PostPosted: Fri Sep 16, 2005 10:35 am 
Newbie

Joined: Fri Sep 09, 2005 11:11 am
Posts: 19
<class name="Person" table="PERSON">
<id name="id" type="long" column="ID">
<generator class="sequence">
<param name="sequence">person_seq</param>
</generator>
</id>
<property name="name"/>
<one-to-one name="employee" class="Employee" cascade="true"/>
</class>
<class name="Employee" table="EMPLOYEE">
<id name="id" type="long" column="ID"/>
<property name="title"/>
</class>

===========
public class Person
{
private String name;
private Employee employee;
/* getter and setter methods */
}
============
I am hoping session.save(person) would insert a record into both PERSON and EMPLOYEE tables where PERSON.id = EMPLOYEE.id.. I think the mapping isn't quite correct..... Any help would be grateful.

Many Thanks.
zollen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 10:51 am 
Beginner
Beginner

Joined: Tue Apr 05, 2005 4:27 pm
Posts: 40
Location: canada
i'm kind of surprised you don't get an xml parsing error on this... cascade="true" isn't valid... try changing the cascade value to all or save-update

<one-to-one name="employee" class="Employee" cascade="save-update"/>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 16, 2005 10:54 am 
Beginner
Beginner

Joined: Tue Jun 28, 2005 4:33 pm
Posts: 21
I think your cascade setting is wrong in your one-to-one. Try cascade="all", not cascade="true"


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