-->
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: Composite Key containing an auto-increment column: possible?
PostPosted: Tue Apr 05, 2005 4:27 am 
Newbie

Joined: Tue Dec 14, 2004 11:49 am
Posts: 2
Location: Toulouse, France
Hibernate version:
2.1.6

Name and version of the database you are using:
MySQL 4.1.10

Hi all,

I'm trying to map a class to a DB table in which the PK is composed of a string column (FK) AND a integer index, which should be autogenerated (it's pretty weird, but I can't change the schema). It's as follow:

CREATE TABLE T_TOTO {
TOTO_NAME VARCHAR (PK)
...
}
CREATE TABLE T_TITI {
TITI_INDEX INTEGER AUTO INCREMENT (PK)
TOTO_NAME VARCHAR (PK) (FK)
...
}

I successfully tried to map other tables with composite PKs by defining Id classes whose fields map the PK columns. In this particular case I'm a a loss finding how to retrieve the autoincremented column value from DB. The generator="native" attribute only seems to work for non-composite PKs. I'd like to leverage Hibernate IdentifierGenerator implementations but I can't figure out exactly how I can achieve that.

Any help will be greatly appreciated. Regards,
Baptiste


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.