Home » Search

About GeneratedValue

1-10 of 127Refresh
Manual
102

Auto Generated Values

Marking a field with the @GeneratedValue annotation specifies that a value will be automatically ... @GeneratedValue with the AUTO strategy: @Entity public class EntityWithAutoId1 { @Id @GeneratedValue ... definition is equivalent: @Entity public class EntityWithAutoId2 { @Id @GeneratedValue long
JPA Doc
93

javax.persistence.GeneratedValue

javax.persistence Annotation GeneratedValue Target: Fields (including property get methods) Provides for the specification of generation strategies for the values of primary keys. The GeneratedValue ... conjunction with the Id annotation. The use of the GeneratedValue annotation is only required
JPA Doc
87

GeneratedValue.generator

Annotation Element javax.persistence.GeneratedValue String generator (Optional) The name of the primary key generator to use as specified in the SequenceGenerator or TableGenerator annotation. Defaults to the id generator supplied by persistence provider. Default value: "" Since: JPA 1.0
JPA Doc
87

GeneratedValue.strategy

Annotation Element javax.persistence.GeneratedValue GenerationType strategy (Optional) The primary key generation strategy that the persistence provider must use to generate the annotated entity primary key. Default value: javax.persistence.GenerationType.AUTO Since: JPA 1.0
JPA Doc
82

JPA Annotations for Value Generation

Automatically generated values are mainly useful for primary key fields, but are supported by ObjectDB also for regular (non primary key) persistent fields. At the field level, the @GeneratedValue with an optional GenerationType strategy is specified: The @GeneratedValue annotation
Manual
24

JPA Primary Key

key field: @Entity public class Project { @Id @GeneratedValue long id; // still set ... . The @GeneratedValue annotation specifies that the primary key is automatically allocated by ObjectDB. Automatic ... If an entity has a primary key field that is not marked with @GeneratedValue, automatic primary key
Tutorial
20

Step 2: Define a JPA Entity Class

.GeneratedValue; import javax.persistence.Id; @Entity public class Guest implements Serializable ... @GeneratedValue Long id; private String name; private Date signingDate
Tutorial
20

Step 2: Define a JPA Entity Class

.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public ... ; // Persistent Fields: @Id @GeneratedValue Long id; private String name; private
Tutorial
20

Step 2: Entity Class and Persistence Unit

.GeneratedValue; import javax.persistence.Id; @Entity public class Guest implements Serializable { private static final long serialVersionUID = 1L; // Persistent Fields: @Id @GeneratedValue
Tutorial
20

Step 2: Entity Class and Persistence Unit

.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax ... serialVersionUID = 1L; // Persistent Fields: @Id @GeneratedValue Long id