简体   繁体   中英

Change JPA Entities Id Generation Streategy

There is a JSF/JPA application with EclipseLink2 which has about 40 different Entity classes. The method used to generate the id for every Entity class is AUTO.

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;

After about one weeks run in production, the Id numbers has passed more than 10,000. I am worries about the possibility of running out the long numbers in few years time.

So I searched the net and changed the Id Generation Strategy as below.

@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "item_entity_seq_gen")
@SequenceGenerator(name = "item_entity_seq_gen", sequenceName = "ITEM_ENTITY_SEQ")
Long id;

But when a new Entity is been created, there is an error as follows.

How can I change the auto generation strategy so that there will be no threat to running out of long ids after the development stage.

Thanks in advance

正如评论中的isnot2bad所述,如果自动生成的ID几乎用完了,我已经放弃了生成单独ID的新方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM