Skip to main content

Entity Classes and Mapping: @Entity, @Table, @Id, @Column, @Transient, @Enumerated, java.time

Learn Entity Classes and Mapping: @Entity, @Table, @Id, @Column, @Transient, @Enumerated, java.time (Phase 2 · Hibernate Core Concepts (Essential), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

A basic entity • An entity is a class mapped to a table. Requirements: annotated @Entity , an @Id field, a no-argument constructor (at least protected ), not final (Hibernate creates proxy subclasses), non-final persistent fields/methods. • @Table(name, schema, uniqueConstraints, indexes) sets the table; @Column(name, nullable, length, unique, precision, scale, updatable, insertable, columnDefinition) customises a column. Without annotations, a field maps to a column of the same name (Spring Boot's naming strategy converts camelCase to snake_case ).

More lessons in Phase 2 · Hibernate Core Concepts (Essential)