ObjectDB ObjectDB

Internal Website Search

1-10 of 139 resultsRefresh


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


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


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

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 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

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 ... Key If an entity has a primary key field that is not marked with @GeneratedValue, automatic primary

Step 2: Entity Class and Persistence Unit

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

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

Step 2: Entity Class and Persistence Unit

; import java.sql.Date; import javax.persistence.Entity; import javax.persistence.GeneratedValue ... static final long serialVersionUID = 1L; // Persistent Fields: @Id @GeneratedValue

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

Getting Started

ObjectDB is very easy to use. Follow the Getting Started Tutorial and the Quick Tour manual chapter and in minutes you may be able to write and run first Java programs against ObjectDB.

Prior knowledge or experience in database programming (SQL, JDBC, ORM, JPA, etc.) is not required, but some background in using the Java language is essential.

Need Help?

  1. Search ObjectDB website
  2. Read the FAQ
  3. Follow the Tutorials
  4. View or post in the forum
  5. Search or file an issue
  6. Contact support