@Id
@Id is a persistence annotation that marks a field or property as the identifier of a persistent entity or object.
Spring in Action, Sixth Edition
@Id is a Spring Data JDBC annotation that marks a domain-property field as the persistent identity of an object.
- How it is used
- Marks the property that identifies a persisted domain object, row, or document.
- How deep it goes
- Explains placement, supported identifier examples, and namespace differences, but does not detail identifier-generation internals.
- Examples
- Uses TacoOrder, Taco, Ingredient, and IngredientRef classes with Long or String identity properties.
- What you can do after
- Apply the correct @Id variant to identity properties in Spring Data JDBC, JPA, or MongoDB domain types.
Java Persistence with Spring Data and Hibernate epub
@Id is the JPA annotation that marks a persistent property or field as an entity identifier.
- How it is used
- Marks the property that exposes database identity for JPA entities and Spring Data JDBC aggregates.
- How deep it goes
- Explains required identifiers, default ID mapping, field access, generated values, and explicit column mapping without covering composite identifiers.
- Examples
- Uses generated Long ids on Item and an explicitly mapped ID field on a Spring Data JDBC User.
- What you can do after
- Apply it via JPA or Spring Data JDBC to map entity identity and support identifier-based persistence and lookup.
Read how Java Persistence with Spring Data and Hibernate epub explains @Id →
Spring Start Here, Second Edition
The @Id annotation identifies the property or field that uniquely identifies a persistent entity.
- How it is used
- Marks the model field Spring Data JDBC uses to identify a table’s primary key.
- How deep it goes
- Defines the annotation’s role and shows a model example, but does not explain annotation internals.
- Examples
- Shows @Id on the id field of an Account model mapped to an account table.
- What you can do after
- Understand how to mark a Java model field as its table’s primary key.
Also covered in
What to know first
- database tableA database table is a relational data structure that organizes records into rows whose values correspond to defined columns.
Related concepts
- unique identifierconfigures · A unique identifier is a value or name that distinguishes an entity or record from others within a defined scope or namespace.
- entityconfigures · An entity is a distinct, identifiable object, concept, participant, or record represented in a system's model or data.
- Spring Data JDBCused by · Spring Data JDBC is a Spring Data module that provides repository-based access to relational databases through JDBC without requiring a full object-relational mapping framework.
- Hibernateconfigures · Hibernate is a Java object-relational mapping and persistence framework that maps Java objects to relational database data and manages their persistence.
Questions about @Id
What is @Id?
@Id is a persistence annotation that marks a field or property as the identifier of a persistent entity or object.
Which Manning books explain @Id?
Spring in Action, Sixth Edition, Java Persistence with Spring Data and Hibernate epub and Spring Start Here, Second Edition.
What should I know before learning @Id?
Manning books that teach @Id usually introduce database table first.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


