What is Spring Boot's default database?
Spring Boot does not ship a default database, but it auto-configures an embedded H2 database when no DataSource is set and H2 is on the classpath.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Spring Boot does not ship a default database, but it auto-configures an embedded H2 database when no DataSource is set and H2 is on the classpath.
Add spring-boot-starter-data-jpa, set the datasource, write jakarta.persistence entities and a JpaRepository. Boot configures Hibernate and transactions for you.
With Spring Data JPA, repository interfaces are detected by scanning, so @Repository is optional; it still matters for custom DAOs and implementations.
Implement the DAO pattern in Java with a generic interface, a JPA EntityManager implementation, Optional results and service-level transactions.
A Data Access Object hides how data is stored behind an interface. See a JDBC example, how DAOs differ from repositories, and when Spring Data replaces them.
The repository pattern hides data access behind a domain-focused interface. Learn its main advantages, a Java example, and when it adds too much ceremony.
Spring Data generates repository implementations from interfaces. Learn derived queries, @Query, projections, paging, custom fragments and how to test them.
The repository pattern puts a collection-like interface between business logic and storage. See plain Java and Spring Data JPA examples.
An EntityGraph controls which associations load with an entity for a single query. See named and dynamic graphs, fetchgraph vs loadgraph and Spring Data JPA usage.
CriteriaBuilder creates type-safe JPA queries, predicates and expressions in Java code instead of JPQL strings. See how to use it for dynamic filters.
Build JPA queries at runtime with CriteriaBuilder, Root and Predicate, add only the filters the user supplied, and keep them type-safe and injection-proof.
The JPA Criteria API builds type-safe, dynamic queries from Java objects instead of strings. See how it works with the metamodel, joins and optional filters.
Speed up JPA writes with Hibernate JDBC batching: configure batch size, use sequence ids, flush and clear per batch, and choose bulk JPQL for uniform updates and deletes.
@Transient marks an entity field as non-persistent so JPA never stores or loads it. See when to use it, with Jakarta Persistence examples.
Define a Java DTO as a record or plain class, map entities to it, validate input and keep request and response shapes separate.
EntityManagerFactory builds JPA metadata once and creates short-lived EntityManager instances. Learn its lifecycle, thread safety and Spring Boot usage.
Optimistic locking in JPA uses a @Version field to detect conflicting updates without database locks. See setup, exception handling and retries.
In JPA, @Transactional scopes the persistence context and the commit or rollback of changes. See dirty checking, lazy loading and read-only use.
Declare repository methods such as findByLastNameAndDepartment and Spring Data JPA builds the query for you. Covers keywords, paging, projections and limits.
@Query overrides derived queries with your own JPQL or native SQL. Learn how Spring Data JPA resolves it, binds parameters, returns projections and handles paging.