-->
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.  [ 1 post ] 
Author Message
 Post subject: Can Hibernate generate one sequence per table?
PostPosted: Fri Apr 28, 2006 10:49 pm 
Newbie

Joined: Fri Apr 28, 2006 10:00 pm
Posts: 1
Hi, all.

I'm using Hibernate annotation and PostgreSQL. I use the following as every entity id mapping:

Code:
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)


But Hibernate only generate one sequence named as "hibernate_sequence" for me. The types of the entity id are not all Integer, but some Short, when the value that sequence generated is greater than 32767, there will produce a error when insert it into a table which id's type is Short.

If I specify one sequence per table manually as the following, when the customer use MS SQL Server, I must change the strategy to "GenerationType.AUTO" back again.
Code:
@javax.persistence.SequenceGenerator(
    name="SEQ_STORE",
    sequenceName="my_sequence"
)
public class Store implements Serializable {
    private Long id;

    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE")


I'd like Hibernate generate one sequence per table.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.