JPA – Persistence Annotations

Most used JPA Annotations

Entity Beans with @Entity

Primary Keys with @Id and @GeneratedValue

Generating Primary Key Values with @SequenceGenerator

Generating Primary Key Values with @TableGenerator

Compound Primary Keys with @Id, @IdClass, or @EmbeddedId

Database Table Mapping with @Table and @SecondaryTable

Persisting Basic Types with @Basic

Omitting Persistence with @Transient

Mapping Properties and Fields with @Column

Modeling Entity Relationships

Modeling @OneToOne relationship

Modeling @OneToMany relationship

Modeling @ManyToMany relationship

Mapping Inheritance Hierarchies

Single Table – @Inheritance(strategy = SINGLE_TABLE)

Joined Table @Inheritance(strategy = JOINED)

Table per Concrete Class @Inheritance(strategy = TABLE_PER_CLASS)

Other JPA 2 Persistence Annotations

Temporal Data with @Temporal

Element Collections with @ElementCollection