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.