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.  [ 5 posts ] 
Author Message
 Post subject: composite id
PostPosted: Mon Mar 21, 2005 4:04 pm 
Newbie

Joined: Mon Mar 21, 2005 3:45 pm
Posts: 2
Hibernate version: 2.1.6
Name and version of the database you are using:mysql 4.0.16

Hi! I'm in truoble and I couldn't find the solution yet.
I've searched the web once and again and nothing.

My problem is that I have a table with composed id and one of the key fields is of the type "autoincrement". I need to know which number was assigned to this field, but the object returned by the save message of Session class has null as value of the variable corresponding to this field.

Any ideas? Thanx in advance.

Gabriel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2005 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
My problem is that I have a table with composed id and one of the key fields is of the type "autoincrement".


this is not a problem, this is a solution :)
this field is enough to manage your object id, forget composite-d just map this column as the <id/> and the other as a not-null property

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 21, 2005 5:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well he will probably run into trouble if he has foreign keys that points to these two at the same time. but then again he should be able to just map the unqiue part and then just maintain the other property in code.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: opinion
PostPosted: Wed Mar 23, 2005 9:44 am 
Newbie

Joined: Mon Mar 21, 2005 3:45 pm
Posts: 2
All right. It worked, but... I must remember to do this everytime I modify the database structure. This is because I'm using middlegen. So then I must touch the generated code manually.

I consider this is a bug... can it be reported as it? would it be propper?

Thanx in advance,

Gabriel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 11:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well its a broken model so no I would not consider it a bug.

You could also try and use the SelectGenerator which allows you to go fetch stuff via an select. but i don't know if that will help you.

_________________
Max
Don't forget to rate


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