This application demonstrates the usage of One-to-one bi-directional mapping. We will take the example of User and User details to understand the working of one to one relationship in JPA.
-
Java - 1.8.x
-
Maven - 3.1.1
-
MySQL - 5.7.12
1. Clone the application
git clone https://gitlab.com/scbushan05/springjpa-one-to-one.git
2. Create Mysql database
create database ecom
3. Change mysql username and password as per your installation
-
open
src/main/resources/application.properties
-
change
spring.datasource.username
andspring.datasource.password
as per your mysql installation
4. Build and run the app using maven
mvn package
A new JAR file will be generated at project/target/springjpa-0.0.1-SNAPSHOT.jar
5. Run the app
java -jar springjpa-0.0.1-SNAPSHOT.jar
The app will start running at http://localhost:8080/springjpa/v1.
The app provides the following features -
1. Create User
2. Create User details
You can find more examples on my blog as well as on my youtube channel -