-->
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: Sequence generator for other than identity fields?
PostPosted: Wed Apr 18, 2007 5:35 am 
Newbie

Joined: Wed Apr 18, 2007 5:31 am
Posts: 1
Hi,

This may be a stupid question, but I would like to create a new sequence and and tie it to a field that is not @Id, so that the value is auto-incremented for each new stored instance.

Is this possible, and if it is, how do I define it with Java annotations?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 3:56 pm 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
I have the same problem, anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 9:49 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,

I don't know if we can have non-id column values being mapped to a sequence through Hibernate.

But, if the need is just to get that behaviour, you can try this.
( just a hack. unaware of pitfalls, if any )

public class MyModel {
...
Integer id ;
Integer dummy ;
....
public Integer getDummy() {
return id ;
}
}


and then map id to a sequnce. ( normal way )

--------------------------------------------------------------
Rate the reply if you find it helpful


Last edited by pramodkp on Fri Apr 20, 2007 12:03 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 19, 2007 10:18 am 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
Thanks for the reply! The problem is getting both id and dummy to be generated by different sequence generators...


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.