-->
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: Userdefined ID Generation
PostPosted: Wed Jul 06, 2011 12:55 pm 
Newbie

Joined: Wed Jul 06, 2011 12:49 pm
Posts: 3
Hi there...

I am new to hibernate. I am learning and enjoying it. Please help me with this..
I want to generate a primary key, composed of a sequence value,a fixed string and date. I want to concat these together in a certain manner to form the primary key. How can I do that using @Id and @GeneratedValue annotations???


Top
 Profile  
 
 Post subject: Re: Userdefined ID Generation
PostPosted: Fri Jul 08, 2011 10:56 am 
Newbie

Joined: Thu Apr 21, 2011 8:59 am
Posts: 14
You might try looking at using composite primary key as Id.
Some information at http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#d0e2177

_________________
Lokesh, C
( SCBCD 5, CCENT, SCJP 5 )


Top
 Profile  
 
 Post subject: Re: Userdefined ID Generation
PostPosted: Fri Jul 08, 2011 12:13 pm 
Newbie

Joined: Wed Feb 13, 2008 7:28 pm
Posts: 5
I think you need a custom generator class...by using the @GenericGenerator annotation.

Here's an example I found via Google: http://blog.anorakgirl.co.uk/?p=43

It's not exactly the same, but it shows you how to use a custom generator.


Top
 Profile  
 
 Post subject: Re: Userdefined ID Generation
PostPosted: Sun Jul 10, 2011 3:30 am 
Newbie

Joined: Wed Jul 06, 2011 12:49 pm
Posts: 3
jraven76 wrote:
I think you need a custom generator class...by using the @GenericGenerator annotation.

Here's an example I found via Google: http://blog.anorakgirl.co.uk/?p=43

It's not exactly the same, but it shows you how to use a custom generator.



Thanks...solved my need


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.