Use the Repository pattern to simplify, structure and expose your database accesses
In a business application, access to data must be reliable, structured and easy to maintain. This is precisely the role of the Repository pattern, which Spring Data illustrates through a rich set of tools dedicated to both relational databases (JPA) and NoSQL databases (Elasticsearch, MongoDB...).
This training course will teach you how to design a clear, reusable persistence layer with Spring Data. You'll discover how to create and extend repositories, formulate simple or complex queries (examples, derivations, @Query, advanced searches), and take advantage of pagination, transactions and REST integration via Spring Data REST.
Practical exercises will enable you to connect repositories to a business layer, then expose them as ready-to-consume REST APIs, with fine-grained management of projections, HTTP status and errors. You'll also work on JPA and Elasticsearch to cover different data access needs.
You'll learn how to build a modern, testable data access layer that meets the requirements of today's Java applications.
Is it for you ?
Developers and architects.
Prerequisites
This course requires a sound knowledge of the basics of Java programming (principles of object-oriented programming, generic types, annotations, lambda expressions), Spring and Spring boot and experience of working with Eclipse or IntelliJ.
What You'll Walk Away With
- ✓ Design a robust data access layer using the Repository pattern and Spring Data
- ✓ Implement CRUD operations, advanced queries, and pagination across SQL and NoSQL databases
- ✓ Map domain entities efficiently with Spring annotations and manage transactions
- ✓ Expose repositories as REST APIs with projections, error handling, and event hooks
- ✓ Integrate Spring Data JPA and ElasticSearch into a tested, high-performance backend application
Training content
1 Introduction
- The different types of database (SQL, NoSQL).
- Non-blocking execution of I/O operations.
- The role of a connection pool.
- Transactions and ACID principles.
- Object/database mapping.
- Presentation of the Repository pattern and Spring Data.
Practical application: getting to grips with a Spring application (data access, REST API, testing).
2 Spring Data repositories
- Mapping model entities to the database using Spring annotations.
- Create, read, update and delete operations.
- Pagination and classification for paginated queries.
- Example queries for multi-criteria searches.
- Derived queries for customized searches.
- @Query annotation for native queries.
- Application of transactions.
- The specifics of two Spring Data variants: Spring Data JPA and Spring Data ElasticSearch.
Practical application: creating JPA and ElasticSearch repositories, using them in a backend application.
3 The Spring Data REST extension
- Principle.
- Projections to control resource representation.
- Searches.
- Error handling and mapping to HTTP code.
- Event observers.
Practical application: using Spring Data REST to expose repositories in REST.
📌 Practical information
Our training sessions are offered in Montreal or Quebec City, in person or in a virtual classroom. Dates and locations are specified when you select your session below. If you have any questions, check out our FAQ.