-->
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.  [ 2 posts ] 
Author Message
 Post subject: Specifying sequence name with GenerationType.AUTO
PostPosted: Tue May 01, 2007 5:01 pm 
Newbie

Joined: Tue May 01, 2007 2:59 pm
Posts: 4
Location: San Jose, CA
Hi,

For id generation, I'd like to use sequences on Oracle, and identity on hsqldb. Using:

@GeneratedValue(strategy = GenerationType.AUTO)

works, but I need to use a different sequence name for each table (the default is a single, global sequence called 'hibernate_sequence'). Of course, I can use strategy=SEQUENCE so that I can control the sequence name, but then it doesn't work on hsqldb. Is there any way to use GenerationType.AUTO, and still control the name of the sequence for the cases where the database uses sequences?

Thanks,
Todd Klaus
Kepler Space Telescope
http://kepler.nasa.gov


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 7:35 pm 
Newbie

Joined: Tue May 01, 2007 2:59 pm
Posts: 4
Location: San Jose, CA
To answer my own question, the following works. It uses identity on HSQLDB, and my named sequence on Oracle:

Code:
...

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO, generator="pi_user_seq_gen")
    @SequenceGenerator(name="pi_user_seq_gen", sequenceName="PI_USER_SEQ")
    private long id;

...



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.