-->
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.  [ 4 posts ] 
Author Message
 Post subject: one to many relationship
PostPosted: Tue Sep 07, 2004 4:26 am 
Newbie

Joined: Tue Sep 07, 2004 3:48 am
Posts: 1
Hi,

I was doing one to many relationship in Hibernate.A 'Person' class
has a one to many relationship with 'Identification' class.

Person contains (one)

1) Personid -primary key
2) FirstName

Identification contains (many)

1) id - primary key
2) personid -foriegn key to Person
3) Username

class person contains a list idlist (of type java.util.List) ,each of its location contains an instance of Identification.Also getLIdentificationist() and
setIdentificationList(list ) methods.

When I load a session for a particular person into the session automatically it takes the value from identification table and stores in idlist of person class.

I set an identification through the setIdentificationList(list )
method of person and I called session.save(person) method.

The values are inserted into person table,but the values to Identification are not inserted.(!! It is possible if I give session.save(identification) aswell )

While selecting it is automatically taken from the identification table but while inserting it is not reflected in table Identification.

Please tell me why this problem comes??????

Nobi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 4:35 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
Please tell me why this problem comes??????


ouch ouch ouch,
note that the following is not a rude answer.

1- read the red card
2- read the reference guide
3- read parent child examples
4- if possible read hibernate in action

there are too many things you're not doing well

trust me, you need to read all this stuff or get commercial training

See you soon with your mapping files after having read the docs

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Did you use "assigned" as the id generator?
PostPosted: Thu Sep 09, 2004 3:49 am 
Newbie

Joined: Thu Sep 09, 2004 2:03 am
Posts: 7
if so, and you assigned id for your object, Hibernate will be confused, and mistake it as a SAVED ONE for the default value of "unsaved-value" is "null". Since your id is not null already, Hibernate makes a RIGHT decision based on "unsaved-value" but , it's a wrong decisin for you.

There is a tempory way to solve it : set "unsaved-value" to "any".

Or, you can give up using "assigned" as the id generator!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 4:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(Or you can use an Interceptor, as per the docs.


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