You probably already used the @GeneratedValue annotation to tell Hibernate to use a database sequence or an auto-incremented database column to generate your primary key values. If you want to use a custom generator, you need to define the generator in a @GenericGenerator annotation and provide the fully-qualified classname as the strategy. Primary Key Generation Defaults. In the descriptions of the @GeneratedValue, @SequenceGenerator, and @TableGenerator annotations in the Java Persistence Specification, certain defaults are noted as specific to the persistence provider. The default persistence provider's primary key generation defaults are listed here. @GeneratedValue defaults are as follows. May 31, 2017 It is the name of the primary key generator as specified in the @SequenceGenerator or @TableGenerator annotation. These two annotations controls how database sequence or table is mapped. @SequenceGenerator and @TableGenerator can be used on the entity class or on the primary key field or property.
This annotation defines a primary key generator that may be referenced by name when a generator element is specified for the
GeneratedValue annotation. A sequence generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across all generator types).
name
sequenceName(Optional) The name of the database sequence object from which to obtain primary key values.
Defaults to a provider-chosen value.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |