-->
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: one-to-one mapping problem
PostPosted: Tue Apr 13, 2004 5:56 pm 
Newbie

Joined: Tue Apr 13, 2004 4:58 pm
Posts: 4
I need help with one-to-one mapping.

I have two classes People and PeopleLogin
They both share the same primary key. People can have 0-1 people login but for each entry in people login there has to be people record.

When I do save on people with peoplelogin
then hibernate tries to "insert to people" and update on "peoplelogin" where it should try to do insert on both the tables.

mapping looks likebelow

<class name="PeopleLogin" table="people_logins" dynamic-insert="false" dynamic-update="false">
<id name="id" column="PERSON_ID" class="People" type="long" unsaved-value="null">
<generator class="foreign">
<param name="property">people</param>
</generator>
</id>
<one-to-one name="people" class="People" />
</class>


<class name="People" table="Peoples" dynamic-insert="false" dynamic-update="false">
<id name="id" column="PERSON_ID" type="long" unsaved-value="null">
<generator class="increment"/>
</id>

<one-to-one name="login" class="PeopleLogin" constrained="false" cascade="all"/>

</class>

My save looks like

People people = new People();
PeopleLogin login = new PeopleLogin();
people.setLogin(login)
session.save(people);



Hibernate: insert into Peoples (PERSONTYPE_ID, PRIMARY_EMAIL, PERSON_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

Hibernate: update people_logins set LOGIN_NAME=?, PASSWORD=?, STATUS_FLAG=?, STATUS_DATE=?, CREATE_DATE=?, CREATED_BY=?, UPDATED_BY=?, UPDATE_DATE=? where PERSON_ID=?

Why? Please help

I donot want to have bidirectional mapping from people-login to People
I just need unidirectional from people to peopleLogin but I couldn't.

Vandana


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.