views:

15

answers:

1

Hello,

I am using @Id with @GeneratedValue(strategy=GenerationType.TABLE), just checked that hibernate have created a table hibernate_sequences, but the column type for the sequence_next_hi_value is an int(11). I have some entities (I mean tables) that have an id field of type bigint(20), will that works ? and when my table reach the number of rows I am expecting ?

thanks

+1  A: 

(...) hibernate has created a table hibernate_sequences, but the column type for the sequence_next_hi_value is an int(11). I have some entities (I mean tables) that have an id field of type bigint(20), will that works ?

Yest, this will work.

and when my table reach the number of rows I am expecting?

I'm not sure I understood that part. But if the question is about running out of numbers, here are some numbers from the JPA wiki book:

Running Out of Numbers

One paranoid delusional fear that programmers frequently have is running out of sequence numbers. Since most sequence strategies just keep incrementing a number it is unavoidable that you will eventually run out. However as long a large enough numeric precision is used to store the sequence id this is not an issue. For example if you stored your id in a NUMBER(5) column, this would allow 99,999 different ids, which on most systems would eventually run out. However if you store your id in a NUMBER(10) column, which is more typical, this would store 9,999,999,999 ids, or one id each second for about 300 years (longer than most databases exist). But perhaps your system will process a lot of data, and (hopefully) be around a very long time. If you store your id in a NUMBER(20) this would be 99,999,999,999,999,999,999 ids, or one id each millisecond for about 3,000,000,000 years, which is pretty safe.

But you also need to store this id in Java. If you store the id in a Java int, this would be a 32 bit number , which is 4,294,967,296 different ids, or one id each second for about 200 years. If you instead use a long, this would be a 64 bit number, which is 18,446,744,073,709,551,616 different ids, or one id each millisecond for about 600,000,000 years, which is pretty safe.

IMO, an int(11) with a default allocation size of 50 gives you some time.

Pascal Thivent
Many thanks ... !