Spring Data JPA Maven Dependency <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> Database Entity In domain or entity package you can define a Database Entity: @Entity (1) public class Book { @Id (2) @GeneratedValue (3) @UuidGenerator (4) @JdbcTypeCode(SqlTypes.CHAR) (5) @Column(length = 36, columnDefinition = "varchar(36)", updatable = false, nullable = false) (6) private UUID id; @Version (7) private Integer version; @CreationTimestamp (8) private LocalDateTime creationDate; @UpdateTimestamp (9) private LocalDateTime updateDate; // Other fields, Constructors, Getters and Setters, toString(), equals(Object obj) and hashCode() } 1 @Entity specifies that the class is a Database Entity. 2 @Id specifies the primary key of an Entity. 3 @GeneratedValue specifies the generation strategy for the value of primary key. See 🟣 GenerationType for generation strategies. AUTO selects SEQUENCE, TABLE, or UUID based on the Entity identifier type and capabilities of the database. 4 @UuidGenerator specifies that an Entity identifier is generated as a UUID type. 5 @JdbcTypeCode specifies the JDBC type-code to use for the column mapping. 6 @Column specifies the mapped column for a field. If no @Column is specified, the default values apply. 7 @Version specifies the version field that serves as its optimistic lock value. The version is used to ensure integrity when performing the merge operation and for optimistic concurrency control. 8 @CreationTimestamp specifies that the annotated field is a generated creation timestamp. The timestamp is generated just once, when an entity instance is inserted in the database. 9 @UpdateTimestamp specifies that the annotated field is a generated update timestamp. The timestamp is regenerated every time an entity instance is updated in the database. Repository When we run the application, Spring Data JPA is going to provide us a Repository implementation. It means that we only have to define a Repository interface. ⚪ CrudRepository<T,ID> Repository for generic CRUD operations on a Repository for a specific type: T is the domain type the Repository manages, ID is the type of the id of the Entity the Repository manages. public interface BookRepository extends CrudRepository<Book, UUID> {} ⚪ ListCrudRepository<T,ID> Extension to ⚪ CrudRepository<T,ID> returning ⚪ List instead of ⚪ Iterable where applicable. ⚪ PagingAndSortingRepository<T,ID> Repository fragment to provide methods to retrieve entities using the pagination and sorting abstraction. In many cases this will be combined with ⚪ CrudRepository<T,ID> or similar or with manually added methods to provide CRUD functionality. ⚪ ListPagingAndSortingRepository<T,ID> Extension to ⚪ PagingAndSortingRepository<T,ID> returning ⚪ List instead of ⚪ Iterable where applicable. ⚪ JpaRepository<T,ID> JPA specific extension of Repository. Extension to ⚪ ListCrudRepository<T,ID> and ⚪ ListPagingAndSortingRepository<T,ID> which can also Query by Example.