-->
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: How to map a sequenced composite-id w/o using a new class
PostPosted: Mon Nov 23, 2009 7:45 am 
Newbie

Joined: Thu Nov 19, 2009 5:38 am
Posts: 4
Hi all.

I have a transactions table, with a sequence id generated by mysql.
<id name="id" type="long" column="ID">
<generator class="native"/>
</id>

Now, i want to add a new field to the pk, being it a property of the class, so the new primary key would be

<id, dateField>

How can i map this to hbm.xml files, without defining a new class ?

I've seen the <composite-id>, but i can't find how to keep the id field being auto-generated ..

Thanks all !


Top
 Profile  
 
 Post subject: Re: How to map a sequenced composite-id w/o using a new class
PostPosted: Mon Nov 23, 2009 9:51 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Hibernate Reference says:
Quote:
You cannot use an IdentifierGenerator to generate composite keys. Instead the application must assign its own identifiers.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: How to map a sequenced composite-id w/o using a new class
PostPosted: Mon Nov 23, 2009 11:19 am 
Newbie

Joined: Thu Nov 19, 2009 5:38 am
Posts: 4
mmerder wrote:
Hibernate Reference says:
Quote:
You cannot use an IdentifierGenerator to generate composite keys. Instead the application must assign its own identifiers.


Great :-(
So, there's no way to add a field to a primary key already being auto-generated ?


Top
 Profile  
 
 Post subject: Re: How to map a sequenced composite-id w/o using a new class
PostPosted: Mon Nov 23, 2009 11:24 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Not if you want hibernate to generate the schema. You can still go to your db and update it manually, which would not make much sense though.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.