跳到主要內容

發表文章

目前顯示的是 3月, 2009的文章

[Oracle]JPA: How to Configure Primary Key Generation in Oracle

Using Sequence Objects When using a database that supports sequence objects (such as Oracle Database), you can configure JPA to use a database sequence object to automatically generate identifiers for your persistent objects. Using A Default Sequence TopLink JPA can produce a default sequence during schema generation. If you use schema generation, then specify that your identifier should be generated and that the SEQUENCE strategy be used to perform the generation. In the following example, the @GeneratedValue annotation indicates that the identifier value should be automatically generated; a strategy of SEQUENCE indicates that a database sequence should be used to generate the identifier. TopLink will create a default sequence object during schema generation. This object will be used by TopLink at run time. @Entity public class Inventory implements Serializable { @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) private long id; Specifying a