
Explore JPA from basics to advanced topics, including entities, relationships, inheritance, JPQL, criteria queries, and transaction management, with hands-on projects in Spring Data JPA and Spring Boot.
Explore the basics of orm, mapping Java objects to database tables to simplify sql, and see how JPA stores, updates, and retrieves data in Spring Boot rest APIs.
Understand JPA features as a specification with multiple persistence providers like Hibernate, Ibatis, Eclipselink, and Apache Openjpa, and map Java objects to database tables using persistence metadata.
Explore the history of JPA, from its 2006 inception in the EJB 3 spec through JPA 2.0 and beyond, and learn how modern JPA simplifies database access for Java applications.
Explore how JPA and ORM map Java classes to tables, converting transient objects to persistent state and back, with @Entity, @Column, and @Id, Hibernate or Ibatis handling mapping.
Learn how to map a Java class to a database table using JPA metadata, via annotation or XML, and use JPQL for static and dynamic queries.
JPA boosts developer productivity by simplifying configuration and reducing SQL boilerplate. It provides database independence, automatic type handling, and first- and second-level caching to improve performance.
Define a JPA entity with @Entity annotation to map a pojo to a table; fields become columns and instances rows, with Student or a custom name via name attribute.
Explore the entity life cycle in JPA, from transient objects in memory to persistent via a session, then to detached or remove states, with merge and update returning to persistence.
Explore JPA annotations like @Entity, @Table, @Id, and @GeneratedValue and how a POJO becomes a database table with columns and a primary key.
Explore embedding a contact person inside a company entity with embeddable and embedded annotations, using attribute overrides to map fields to contact columns.
Map entities with JPA using annotations or XML to bind classes to relational tables, define id and column mappings, and apply constraints like not null and length for ORM.
Explore how to define relationships between entities in JPA using four annotations: one to one, one to many, many to one, and many to many.
Explain a one-to-one relationship between user and user profile in JPA, using mapped by to add a foreign key from user profile to user, so each user has one profile.
Explore one-to-many and many-to-one relationships in JPA using book and author entities, applying mapped by author and a join column author_id to avoid a junction table.
Establish a many-to-many relationship between book and author in JPA using a join table named book_authors, with sets of authors in books and sets of books in authors.
Explore inheritance strategies in JPA and Hibernate, learn how four mapping approaches store inherited fields across tables, and choose the best strategy for entities like books and blog posts.
Use mapped superclass strategy, the simplest inheritance mapping, where each concrete class—author, book, and blog post—gets its own table with publication fields like id, title, version, and publishing date.
This lecture covers the table per class inheritance strategy in JPA, where the superclass is an entity and each class maps to its table, with author publication relationships via ids.
Discover the single table strategy for JPA inheritance, mapping all hierarchy entities to one table, simplifying schema, avoiding joins, and boosting performance with shared publication fields.
Understand the joined table inheritance strategy, where each subclass has its own table and joins the superclass publication, increasing query complexity and potentially slowing performance.
Explore JPQL, the Java Persistence Query Language, to write queries against entity models rather than database tables. Learn syntaxes, functions, and operators through examples with authors, publications, books, and publishers.
Explore how the select and from clauses work in JPQL, mapping entities to database tables, with an example: select a from author a, returning all author records.
Explore joining multiple entities in JPA by fetching authors and their books via a common foreign key. Learn about theta joins for unrelated entities and why JPA restricts them.
Explore left outer join in JPA to include authors who have not written any books, while returning authors with books. The left join retrieves all authors and their matching books.
Explore implicit joins with path expressions in JPA, using dot notation to navigate entity fields and apply where clauses to filter results with and/or/not operators.
Learn how JPQL operators in the where clause filter records using =, !=, >, >=, <, <=, between, contains, and null checks, including John or Jane.
Explore operators for collection expressions in jpa orm and springdata jpa, including is empty, is not empty, size, and member of for authors and their books.
Learn how projection in the select clause defines which columns to retrieve, using entity attributes and scalar values after joins.
Learn how to obtain unique results in JPQL using the distinct operator, avoiding duplicates by selecting distinct columns like last name from author.
Explore JPQL functions used in select and where clauses, mirroring SQL, and apply examples like upper, lower, current date, substring, trim, length, locate, abs, sqrt, mod, and size.
Explore grouping in JPQL using group by and the having clause, counting by last name, listing non-aggregated attributes, and filtering groups such as last names starting with B.
explore how the order by clause sorts query results in ascending or descending order, using last name ascending and first name descending as a practical example, including dates or numbers.
Explore subselects in JPQL, embedding a count of books per author in the where clause, using aliases from the outer query to return authors with at least one book.
Define and use JPA named queries as statically predefined JPQL strings to organize queries, enforce parameters, and improve efficiency, illustrated with a country entity example.
Explore named queries in JPA by wrapping multiple queries on an entity with @NamedQueries, using parameters for efficient country name filtering and learning how to call them from code.
call named queries at runtime using typed query and query interfaces, instantiated via different entity manager factory methods, to return typed results or raw results.
Explore how JPA criteria API enables dynamic, type-safe queries by obtaining a CriteriaBuilder from entity manager, creating a criteria query with a root, and selecting from country, contrasting with JPQL.
Learn to pass parameters in criteria queries using the criteria builder and parameter expressions, and execute typed queries to fetch countries with population greater than a given value.
Discover how the entity manager and entity manager factory interact: the factory creates managers tied to a persistence unit, while each manager handles crud within a persistence context.
Understand the persistence context in JPA as a short-lived set of managed entities that uses the entity manager's first-level cache to detect changes and synchronize with the database during transaction.
Explore the two persistence contexts in JPA: the transaction persistence context, bound to the transaction, and the extended persistence context, accessible beyond transaction boundaries.
Explore how JPA handles transactions using two persistence contexts: transaction-scoped and extended. Persist operations within a transaction auto-commit, while extended context saves only upon closing or removal.
Understand lazy and eager fetch types in JPA and how to load related data, such as one-to-many relationships between universities and students, only when needed to optimize performance.
Explain optimistic locking in jpa, which assumes concurrent conflicts and detects conflicting updates without locking, and contrast it with pessimistic locking that locks data during a transaction to prevent conflicts.
See how Hibernate uses a version field to detect conflicting updates in a product entity, and how a higher database version triggers an optimistic lock exception.
Enable optimistic locking in a Spring Boot service using Spring Data JPA; annotate the update method with transactional to read and update the product within a transaction, enabling version checks.
Learn how to implement pessimistic locking by annotating the repository's find by id method with a lock, locking the selected row to prevent concurrent updates until release.
Enable pessimistic locking with a transactional method in Spring Data JPA by reading, updating, and saving a product entity, with the transactional annotation controlling the lock until commit or rollback.
Configure custom attribute converters to map enums to compact database values and back, using auto-apply converters to store short names while displaying full enum values.
Discover performance optimization techniques for JPA and Spring Data JPA, including lazy loading, pagination, caching, batch processing, and avoiding the N plus one select in repository queries.
Explore performance optimization with lazy loading in JPA, loading author data without fetching all books upfront and only retrieving related records when needed.
Learn to optimize performance with pagination in Spring Data JPA by lazy loading data in pages, using a fixed page size and page number.
Explore how caching reduces database hits with a multi-level cache in JPA and Hibernate. Enable caching in Spring Data JPA and apply first level, second level, and query caches.
Prevent the N+1 select problem by using join fetch to retrieve related data in a single query. Replace iterative per-item queries with a join fetch to boost database performance.
optimize queries by balancing join usage and using criteria builder API for dynamic queries; rely on JPA repository methods like find by, delete in batch, and flush after saves.
Engage in hands-on practicum with JPA and Spring Data JPA, building Maven projects, using bare JPA with EntityManager and Java 17, and another with Spring Boot and Spring Data JPA.
Explore future trends in Java enterprise development with Spring Data JPA, including repositories, query DSL, auditing, pagination, and multi-database support from relational databases to Neo4j and MongoDB.
Explore the persistent unit in JPA, defining the entity manager factory and entity manager within a persistence context, choosing between resource local or JTA transactions, and XML definition.
Set up your development environment by installing JDK 17 for Windows 64 via MSI and selecting an IDE such as IntelliJ, Eclipse, or NetBeans, then configure Maven in your classpath.
Identify and configure Maven dependencies for JUnit 5, Mockito, and Hibernate, plus an in-memory (H2) database or alternatives, and set up essential Maven plugins and reporting tools.
Configure the persistence unit in META-INF/Persistence.xml using Hibernate to connect to an in-memory H2 database or MySQL, setting dialect, show_sql, and hbm2ddl.auto options with resource local transactions.
Map school, student, tutor, teacher, and person entities with table-per-class inheritance. Define one-to-many between school and student and many-to-many between student and teacher, with cascading and a named query.
Set up a Twitter repository using an entity manager and factory for a persistence unit, and implement add, find, search, update, and delete operations within transactions.
Set up school and student repositories using JPA and Spring Data JPA, injecting the entity manager factory and entity manager, and implement add, find, update, delete, and close operations.
Set up the teacher repository with an entity manager and factory, define constructors, and perform add, find by id, update, and delete operations within a resource-local persistence unit transaction.
Run a main method to test jpa-based repositories (student, tutor, school) with lazy loading, queries, criteria builder, and prints, using maven, Java 17, and persistence.xml configuration.
Learn to write unit and end-to-end integration tests for a JPA application using JUnit and Mockito, configure an in-memory H2 database, and test repository CRUD operations.
Learn to use Spring Data JPA with Spring Boot, the industry standard. Configure a Maven project on start.spring.io with Java 17, Lombok, Spring Web, Spring Data JPA, and H2.
Explore how pom.xml dependencies configure spring data jpa projects and how application.properties and profile-specific files control local, dev, test, and production settings, including H2 and MySQL databases.
Learn to model a property entity with JPA annotations, create repositories (CRUD, JPA, paging) and a service layer to perform property CRUD operations, with swagger UI testing.
create, list, and delete properties using post requests and repository methods in a jpa spring data app, including registering a user and linking it to a property.
Update property flow through the property controller and service using patch or put to find and update a property, save it, and illustrate Spring Data JPA crud operations.
Learn to write find by queries in Spring Data JPA using an enterprise project with role and address entities, including enum name searches via repository.
Learn to query a city entity with Spring Data JPA using findByLabelContains and findAllByLabel, then apply order by for ascending or descending results.
Discover how to implement find all by queries across related entities in JPA and Spring Data JPA, using owner and id traversal to fetch events created by a specific user.
Explore using find by queries with multiple fields and operators in Spring Data JPA, returning events not expired or canceled and with end dates between two dates.
Learn how to use Spring Data JPA to perform count by, exists by, and delete by queries with simple naming conventions, alongside find by and save.
In this course you will learn about JPA, ORM different concepts about them. Then you will learn about how to use different concepts in real world project. Later you will learn about Entity, Entity Manager, Query, Criteria, Persistence Context, Persistence Unit, Transaction, Lazy loading, Relationships, SpringData JPA. Finally you will learn to use JPA without Springboot and JPA with Springboot by doing two real world projects.
You will about real world uses of SpringData JPA findBy, countBy, existsBy, deleteBy queries.
Following is the list of topics that you will learn in this course:
Introduction to JPA
Overview of Java Persistence API (JPA) Evolution from JPA 1 to JPA 2 Key features and benefits
Entity Basics
Creating JPA entities Entity lifecycle and states Annotations (@Entity, @Id, @GeneratedValue, etc.) Embeddable and embedded objects
Mapping Entities
Mapping entity attributes One-to-One, One-to-Many, and Many-to-One relationships Many-to-Many relationships Mapping inheritance hierarchies (Single Table, Joined, and Table per Class strategies)
JPQL (Java Persistence Query Language)
Overview of JPQL Querying entities with JPQL Named queries JPQL functions and aggregation
Criteria API
Introduction to Criteria API Building type-safe queries Predicate, CriteriaQuery, and CriteriaBuilder
Transactions and Persistence Context
Managing transactions in JPA Entity Manager and Persistence Context Transaction demarcation (declarative and programmatic)
Advanced Mapping Techniques
Embedded objects and collections Lazy and eager loading strategies Optimistic and pessimistic locking Custom converters and mappings
Performance Tuning and Best Practices
Fetch strategies and batching Caching strategies (1st and 2nd level cache) Query optimization Best practices for efficient data access
Integration with Java EE and Spring
Using JPA in Java EE applications Spring Data JPA integration Transaction management with JTA and Spring
Testing and Debugging JPA Applications
Unit testing JPA entities and queries Debugging common JPA issues Integration testing with embedded databases
Migration and Upgrading
Migrating from JPA 1 to JPA 2 Upgrading JPA providers Handling version-specific issues
Future of JPA
Trends and advancements in ORM frameworks JPA vs. other ORM solutions Considerations for modern application development.
After this course you will become pro level developer who will be very confident to work in any project which uses JPA or SpringData JPA.