Entities and mapping

A JPA entity is a class annotated with @Entity whose instances correspond to the rows of a table. @Id designates the primary key (often with @GeneratedValue), @Column specifies the columns. The entity must have a no-argument constructor and must not be final. The schema is managed through migrations.

Example

@Entity
class Client {
    @Id @GeneratedValue Long id;
    @Column(nullable = false) String nom;
}

Related concepts

The whole glossary