[转]Hibernate TableGenerator 生成负数主键

Problem: Using Hibernate’s table generator it starts generating negative ids when exceeding the Integer maximum of 2,147,483,647 .

Solution: Use a Hibernate version of at least 3.5. The older versions only support Integer values when using TableGenerator until Hibernate 3.5.

If you’re using TableHiLoGenerator use at least Hibernate 3.2.3. Long values are supported since this version.

If you’re simply using the @TableGenerator – Annotation it internally uses the TableHiLoGenerator which makes it sufficient to switch to Hibernate 3.2.3 or higher.

你可能感兴趣的:(Hibernate)