
An architecture diagram that depicts the working of Spring Data JPA.
Spring Data JPA, Java Persistence API (JPA), Hibernate, and Databases.
Setting Up Eclipse For Spring Data JPA And REST
Prepare to add a JPA Entity.
Learn to create your JPA entities.
Now we add an Id, its value, and a title (a Column attribute) to our JPA entity.
Learn about creating a Spring Data JPA repository.
Learn how to verify that Spring Data JPA repository is already present and loaded in Spring's application context.
Here's a strategy to fetch Spring Data JPA repository from Spring's application context.
Some clarifications.
Now we fix errors and run our Spring Data JPA application.
Learn how to use a database console to see our JPA data as rows of the database table.
Use Spring Data JPA repository to count instances of a JPA entity.
Learn how to use Spring Data JPA to find and print all instances of a JPA entity. We also match the results with our database.
Learn how Spring Data JPA internally performs its magic and how Hibernate (our JPA) works with databases.
This lecture adds our first Query method to our Spring Data JPA repository.
Understand how our Query method is working according to the Query Creation Mechanism of Spring Data JPA. You should be able to write similar Query methods after completing this lecture.
This lecture demonstrates adding more attributes of different data types to your entity and then viewing your attributes as columns in the database console.
In this lecture you will learn the use of Query Builder Mechanism to write queries that can find and count objects.
In this lecture you will run and experiment with simple findBy & countBy methods. This helps in becoming more hands-on with the concepts you are learning.
We are now writing more complex search queries with Spring Data JPA. You will be able to add search conditions after listening to this lecture.
We are now executing conditional search queries. We create enhanced sample data in the database, execute our search queries, and show search results.
You will now learn the use of countBy methods with conditional search queries in order to count the number of resulting objects.
Learn how to work with time-related data in Java as well as SQL databases. We add Java Timestamps to our JPA entity, run the application, and see the time data in our H2 database.
This lecture introduces the features of SQL timestamps.
This lecture shows official Hibernate documentation and explains how time-related data in Hibernate corresponds to Java classes.
Start learning how to use the java.time package with JPA entities. Also learn how columnDefinition is used.
Follow all steps of this lecture and you'll learn to use LocalDateTime class with JPA in multiple ways.
In this lecture you'll learn how time-related Java classes transform into SQL timestamps. You'll also see the effect of columnDefinition on FSP in our H2 database console.
Experiment with nanosecond values of time and see how values are treated in an SQL database.
Follow this lecture to learn the processing of time data while working with JPA and databases. The lecture shows resulting processed data in the database console.
We are now demonstrating the use of DDL in Spring Data JPA applications.
Follow this lecture to start using Hibernate properties about DDL scripts.
Now we generate our DDL script and start analyzing it to see how DDL maps to database columns.
Map your JPA entities to DDL scripts & to your SQL database.
Learn how Hibernate (our JPA) is internally transforming and handling JPA attributes.
Start learning how to manage time-zones in Spring Data JPA and REST applications.
We are about to start developing REST APIs and test them with Postman.
Specifying versions of Java and Spring Boot in the Maven file.
Follow this (and a few next) lecture(s) to learn how to use a REST controller class in order to build REST APIs around Spring Data JPA repositories.
We are now autowiring our Spring Data JPA repository in our REST controller.
We are now wrapping Spring Data JPA functionality in REST methods.
Learn how you can use Spring's REST controller functionality together with Spring Data JPA repositories.
Follow this lecture to learn how to use Spring annotations to generate JSON REST responses from Spring Data JPA methods.
Listen to this 90 seconds summary of how Spring annotations magically transform data returned by Spring Data JPA into JSON REST responses.
Now we briefly conclude the points we have discussed about REST controller.
You are learning how to expose Spring Data JPA functionality to external applications using Spring's annotations. Now you are ready to access your sample application from your browser.
Learn how you can use a combination of Spring's annotations to serve HTTP GET REST requests.
This lecture demonstrates that JSON objects are empty and we need to fix this problem.
Look how we fix the "empty JSON" problem!
Now you can control which JPA attributes the JSON should render.
Start using my Postman collection to test the sample Spring Data JPA & REST API applications.
In this lecture, you'll inspect all JPA attributes especially time data in JSON format.
Learn Java classes from the java.time package for time-zones and offsets.
Follow this lecture to see how Postman handles JSON representation of time data with time-zones and offsets.
Follow this lecture to learn the use of time data in Spring Data JPA repository methods in order to find database objects that you are looking for.
We are now adding code to enhance our REST API experience with Spring Data JPA. Learn the steps to build REST APIs that expose advanced Spring Data JPA features.
Now we check the versions used to build this enhanced REST application, then see the enhanced sample data to test our REST API, and finally run the application.
This time we are using Spring's annotations for HTTP POST REST to expose Spring Data JPA functionality.
Learn how to configure a POST REST request in Postman, send it over to our live REST application, and receive a response in Postman.
Learn how parameters are included or wrapped in POST request body, sent via REST API calls, and passed to Spring Data JPA for database search.
Learn how to use Spring's annotation to convert a JSON object (from a POST request body, coming via REST) into a Java object.
Now we can run our REST API, send search parameters, receive REST response, examine both the request & response, and finally compare the results with our database table. Follow this lecture to do all this.
This lecture shows you ways in which you can run, rerun, test, retest, and play with the code of your current enhanced version of the REST and Spring Data JPA application.
We have built and tested our REST API and Spring Data JPA repo method with Zoned time data in previous lectures.
This lecture demonstrates the same structure to build a REST API with Offset time data. You will learn the steps that are same as before and also those that are different.
Assignment: Add Two More Repository Methods
Your assignment is to add two more Spring Data JPA repository methods in our ProjectRepository interface.
One of the two new methods will find and bring all the projects whose offsetCompletionDate is BEFORE the given date.
The other method will bring all the projects whose zonedKickOffDate is AFTER the given date.
Your task includes:
Adding the repository methods to our ProjectRepository interface.
Writing the REST API Code for each of the two new repository methods.
Adding the HTTP POST methods to our bilal-spring-jpa-entity POSTMAN collection to test each of the two new ProjectRepository interface methods.
And finally, testing with POSTMAN and verifying the POSTMAN response with the h2 database.
I have attached the solution as a zip file with this video.
Learn how we wrap query data inside a JSON representation of a JPA entity.
Learn the things that happen when you make a REST API call to a Spring Data JPA application.
Learn how Spring Data JPA allows to combine conditions with And & Or.
Now we run the application with "And" combining conditions in our Spring Data JPA repository method, verify search results using application logs, then also write a REST API wrapper method along with a POSTMAN query, and see results of using "And" in the REST API response.
Assignment: Prepare an OR version of the AND method findByDecimalCostGreaterThanAndZonedKickOffDateAfter
I have already demonstrated the bilal-spring-jpa-entity-rest-enhanced4 application in which I explained the AND feature in our findByDecimalCostGreaterThanAndZonedKickOffDateAfter Project Repository method.
Now I would like you to prepare an OR version of the same AND method.
Spring Data JPA reference documentation tells that you can concatenate conditions with both AND and OR. Java programmers can easily understand what OR will do.
Complete all the steps that we did with the And version:
Add the OR method to the Project Repository interface.
Call the repository method from updateMyDB.
Add REST API wrapper.
Send an HTTP POST request from Postman.
Compare the response with our H2 database.
I have attached the solution as a zip file with this video.
Learn how to use Spring Data JPA to search database objects with a column or attribute value falling within a range i.e. between two values.
This lecture demonstrates building REST APIs that bring back database objects with column values falling between a range of values.
This demonstration also includes learning how to pass multiple values of an attribute via REST API requests.
Assignment: Prepare a Decimal Costs version of the findByZonedKickOffDateBetween method
This is another assignment for you that will help you Put Into Practice what you learned from our discussions about the findByZonedKickOffDateBetween Project Repository method.
You are now required to add a new method to the repository similar to the findByZonedKickOffDateBetween method. The new method should bring all project entity objects that have their Decimal Costs between two given amounts.
Do all the steps for the new method that we did for the findByZonedKickOffDateBetween method including REST API testing.
The solution to this assignment is attached as a Zip file with this video.
See how we use Spring Data JPA's countBy feature to build a simple REST API that brings back a count of database objects.
Assignment: The countBy assignment: Add a countBy method for each of the findBy methods in the ProjectRepository interface - One countBy method for each findBy method.
This is an assignment for you. I call it the countBy assignment.
I have demonstrated the use of countByZonedKickOffDateBefore method in the ProjectRepository interface. Now it's time to add countBy methods for each of the findBy methods in the ProjectRepository interface.
countByOffsetCompletionDateAfter for the findByOffsetCompletionDateAfter method
countByOffsetCompletionDateBefore for the findByOffsetCompletionDateBefore method
and so on ...
For each countBy method, you will add a test method call code to the updateMyDB method of the BilalSpringJpaEntityApplication class.
You will also add REST API wrapper methods to the ProjectRestController class and add count REST API calls in the "count By Methods" POSTMAN folder. Run each REST API call and check the responses.
Doing all the steps for each countBy method will be a very useful exercise that will make you hands-on with all the concepts you have learned so far.
The solution, as usual, is attached with this video.
Learn one-to-one mapping between JPA entities.
Learn how to write Spring Data JPA search methods that work with multiple entities.
Now we save multiple JPA entities in the database using Spring Data JPA, look at the database console to see our data, and then run our multiple-entity search queries.
Learn why we need a Join Column and how we can use it to implement one-to-one mapping in JPA.
Learn an important aspect of relationship between JPA entities: Cascading.
Assignment: Add a REST API wrapper method for the multi-entity findByTeam_Name Project Repository method.
This is an assignment for you.
You are required to add a REST API wrapper method in the Project REST Controller class to expose functionality of the findByTeam_Name Project Repository method.
The REST API wrapper will take a Team JSON object, deserialize it, extract the team name from the deserialized Java object, provide the team name to the findByTeam_Name method call, get the search results, serialize the results back to JSON and serve the response to the calling application.
Test the REST API using POSTMAN.
The solution to this assignment is attached as a Zip file with this video.
Our one-to-one mapping is unidirectional (one-way) till now. This lecture introduces bidirectional (two-way) mappings.
Follow the steps to build a bidirectional relationship between your JPA entities.
We add a new Spring Data JPA repo.
Now we use our two repositories for fully bidirectional save & find database operations.
Assignment: Add a TeamRepository method that finds Team JPA entity objects using their Project titles.
This is an assignment for you in which you will add and use an important Spring Data JPA feature related to the bidirectional One-to-One mapping between Project and Team JPA entities.
Notice the TeamRepository interface does not yet have any method. This assignment adds a method to the Spring Data JPA TeamRepository interface.
You are required to add a new method to TeamRepository. The new method will find Team JPA entity objects using their Project titles.
The new method will be very similar to the findByTeam_Name(String name) method of the ProjectRepository interface. Your new TeamRepository method will take a Project title as a parameter and return all the Teams that have their Projects with a matching title.
You will also test your new TeamRepository method by adding a TeamRepository.YOUR_NEW_METHOD call in the updateMyDB method.
The solution to this assignment is attached as a Zip file with this video.
This lecture demonstrates an infinite loop problem with the rendering of bidirectionally mapped JPA entities.
Learn how to use JsonIgnore with bidirectionally mapped JPA entities.
Learn how to solve the infinite loop problem while generating the string representation of bidirectionally mapped entities.
Assignment: Add a REST API wrapper method for the findByProject_Title Team Repository method.
This is an assignment for you which will help you build REST APIs with bi-directional One-to-One mapping between JPA entities along with Spring Data JPA repositories.
Our Project and Team One-to-One mapping is bidirectional, we have our project repository and team repository fully functional with their Spring Data JPA repository methods such as findByProject_Title ready for use.
The REST API service for the findByTeam_Name Project repository method is also working and you have already tested it with POSTMAN.
You can see, there is a small task remaining to be done in this One-to-One bi-directional mapping with Spring Data JPA and REST API arrangement. The small remaining task is to build and test a REST API wrapper for the findByProject_Title Team Repository method.
In this assignment, you are required to perform this remaining task by adding a REST API wrapper method in a Team REST Controller class to expose functionality of the findByProject_Title Team Repository method using a REST API.
The new REST API wrapper method - that you will create - will take a Project JSON object, deserialize it, extract the project title from the deserialized Java object, provide the project title to the findByProject_Title method call, get the search results, serialize the results back to JSON and serve the response to the calling application.
Also test the REST API using POSTMAN.
The solution to this assignment is attached as a Zip file with this video.
This lecture shows another way to implement one-to-one mapping i.e. to use the primary key of one entity to join or map to another.
This lecture teaches you how to use a Join Table in order to implement a one-to-one mapping.
Learn one-to-many and many-to-many mappings between entities.
Look how these one-to-many and many-to-many relationships are mapped in our database tables.
This lecture teaches you to implement one-to-many relationships.
Implement one-to-many cascading.
Learn more about cascading in order to use it in the correct manner.
Implement many-to-many relationships and use them.
We have demonstrated one-to-one, one-to many, and many-to-many entity relationships. Now we put them together with Spring Data JPA and REST.
Now I demonstrate how to use HTTP PUT REST along with Spring Data JPA to save data to database. Moreover, we work with MySQL in this video.
If you're a Java developer and looking to secure your first Spring Data JPA programming job or develop your own REST APIs with Spring Data JPA, this course is the best learning resource you need.
Why should I join this course?
Join this course to discover how Spring Data JPA simplifies database programming. Spring Data JPA is the most popular way to build database applications using Java.
You'll also learn REST API development with Spring Data JPA.
This course is a practical and step-by-step coding exercise along with architectural and conceptual discussions.
What will I be able to do or achieve after completing this course?
You will be able to develop Spring Data JPA applications that use SQL databases.
You'll also be able to build your own powerful REST APIs around Spring Data JPA, which is very useful since majority of real world Spring Data JPA applications are actually REST APIs.
How does the course teach?
In this course, we write and discuss code, work with variety of datatypes in Java, SQL, and JSON, read documentation and relate it with our code, run our sample applications, go through applications logs, verify results by comparing with rows in our database tables, and while doing all this we incrementally build the sample applications of this course.
Is this a hands-on software development course or a theoretical discussion?
It is both! I have been teaching Software courses for more than 20 years. I have mastered the technique of demonstrating practical hands-on work while delivering sound theoretical concepts.
We develop and test a lot of code in the form of sample applications. The video lectures refer to official Spring, Hibernate, SQL, and other documentation to explain how the code is internally working. This technique not only demonstrates programming, it also builds concepts and makes you familiar with the official documentation.
I also provide insights about how stuff works behind the scenes: JPA repositories, Hibernate ORM, and REST API annotations etc.
After completing this course, you'll be able to solve any Spring Data JPA problem yourself, by reading official documentation and using the sample code.
What practical application development steps does this course demonstrate?
The sample applications in this course demonstrate the Query Builder Mechanism of Spring Data JPA with lots of code and discussions. We do this by developing Spring Data JPA repositories.
We also provide Java code that uses our repositories. In addition, we also build REST APIs around our repositories.
We also demonstrate the use of Java data types in Java Persistence API (JPA) entities together with SQL data types in database tables. Data types are the center of all Spring Data JPA applications.
Video lectures use a database console to show database tables along with application logs to show search results.
We use Postman to send REST API requests using JSON messages.
We also demonstrate how JSON is converted to Java, which is fed into Spring Data JPA, and the final response is converted back to JSON that is embedded into the REST API responses.
Sample applications for this course include both Spring Data JPA applications and Postman Collections.
How can I get the most of this Spring Data JPA and REST APIs course?
1. Prepare the development setup as I have described in the course.
2. When you listen to my video lectures, you should try all the code of my sample applications on your own development setup. You should run the sample applications, check the application logs, use the database console, test your REST APIs, and perform all the steps described in my video lectures.
3. You should also read the official documentation that I discuss in the video lectures. I have provided links to the documentation as Resources attached with video lectures.
4. Consult all Resources that I have attached with video lectures. They are all helpful.
5. After performing these steps, write your own code and develop sample applications similar to those I have provided. Don't forget to test your applications in the manner I have tested mine in video lectures.
These steps will turn you into a Spring Dara JPA expert. Guaranteed!
If you perform these steps, send me the sample Spring Data JPA and REST API applications that you have developed. If I like your work, I will promote your resume to potential employers.
Don't hesitate to ask questions.