-->
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: How do I configure hibernate to use a table generator other
PostPosted: Mon Apr 21, 2008 4:48 pm 
Newbie

Joined: Mon Apr 21, 2008 4:38 pm
Posts: 7
Hibernate version: 3.2.1

I'm interested in using a table generator and I've seen mention of different implementations but I don't know how to actually configure hibernate to use anything other than the default. Please note, I am using JPA along with annotations.

So, with that said, how do I configure hibernate to use a table generator other than the default?

Thanks in advance, Tom


Top
 Profile  
 
 Post subject: This should help you...
PostPosted: Mon Apr 21, 2008 7:09 pm 
Beginner
Beginner

Joined: Thu Feb 28, 2008 11:53 am
Posts: 23
though I haven't personally implemented it

Code:
@TableGenerator(name = "unique_generator_name",table="table_name",initialValue=1,...)
public getId(){
    return id;
}



The api should help you with the rest, lookup @TableGenerator, http://www.hibernate.org/hib_docs/ejb3-api/


Top
 Profile  
 
 Post subject: How do I configure hibernate to use a table generator other
PostPosted: Tue Apr 22, 2008 10:00 am 
Newbie

Joined: Mon Apr 21, 2008 4:38 pm
Posts: 7
Thanks for offering the advice (and the pointer to the documentation) but unfortunately, that really doesn't tell me how to use an implementation such as the org.hibernate.id.MultipleHiLoPerTableGenerator class.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 5:13 pm 
Newbie

Joined: Mon Apr 21, 2008 4:38 pm
Posts: 7
Here's what I've uncovered (use the GenericGenerator) as in the following ...

Code:
@Id
@GeneratedValue(generator="hibseq")
@GenericGenerator(name="hibseq", strategy = "org.hibernate.id.enhanced.TableGenerator",
        parameters = {
            @Parameter(name="initial_value", value = "1"),
            @Parameter(name="table_name", value = "hibernate_sequences")
        }
    )
private Long id;


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 22, 2008 5:15 pm 
Newbie

Joined: Mon Apr 21, 2008 4:38 pm
Posts: 7
Oh, I should have noted that I had to upgrade to 3.2.3 (actually, I upgraded to 3.2.6) to take advantage of the enhanced TableGenerator.


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.