Reputation: 3103
EMPLOYEE.java
@Entity
@Table(name="EMPLOYEE")
public class Employee implements Serializable {
@Id
@GeneratedValue( strategy = GenerationType.TABLE)
EMPLOYEE (TABLE)
1 3/13/2013 911 Jack Bauer
32768 3/13/2013 911 Jack Bauer
65536 3/13/2013 911 Jack Bauer
98304 3/13/2013 911 Jack Bauer
HIBERNATE_SEQUENCES(TABLE) HOLDING CORRECT NUMBER
EMPLOYEE 4
Upvotes: 1
Views: 608
Reputation: 2586
@TableGenerator(name="tabgen",table="employee-id",pkColumnName="name",valueColumnName="value",allocationSize=1)
@GeneratedValue(strategy=GenerationType.TABLE, generator="tabgen")
however, its always better to use increment or sequence instead of table generation if you need the ids to be in sequence. the random ids which u see with default table strategy is because of the need to support multiple threads all simulteneously trying to insert.
Upvotes: 3