A unique identifier is an entity property whose value exposes database identity to the application. Entity classes generally require one, while value types are identified through their owning entity. section 5.1.3 section 5.2.2
Use the identifier property consistently across mapped entities:
- Annotate the property with @Id; without additional mapping, it maps to a primary-key column named ID. section 5.2.2
- Prefer a shared property name such as id across domain entities, supporting predictable lookup and mapping conventions. section 5.2.2
- Place @Id on a field when field access is preferred; the persistence provider then accesses fields directly and treats fields as persistent by default. section 5.2.2
- Expose a getter when application code needs the identifier as a handle for retrieving a selected entity. section 5.2.2
Shows a mapped Item entity with an @Id, generated Long identifier, and getter. section 5.2.2








