Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 JPA 上创建序列我通常使用这个 @GeneratedValue(strategy=GenerationType.AUTO) @SequenceGenerator(name="example_sequence", sequenceName="example_sequence")
但我想创建一个也自动生成的序列,但它从 0 增加到 255,当达到这个值时,它从零重新开始
您将需要创建自己的序列生成器
http://www.objectdb.com/api/java/jpa/SequenceGenerator
http://openjpa.apache.org/builds/1.1.0/docs/jpa_overview_mapping_sequence.html
http://blog.cyclopsgroup.org/2007/04/custom-idgenerator-for-jpa-gap-between.html