This project demonstrates a simple Spring Boot application with a one-to-one relationship mapping between two entities using Hibernate and MySQL. The application showcases how to set up and manage one-to-one relationships in a Spring Boot environment.
User and UserProfile.User and UserProfile.Clone the Repository:
git clone https://github.com/Pranaydalvi/SpringBoot_OneToOne_Mapping.git
Navigate to the Project Directory:
cd SpringBoot_OneToOne_Mapping
Configure MySQL Database:
Update the application.properties file in src/main/resources with your MySQL database details:
spring.datasource.url=jdbc:mysql://localhost:3306/your_database
spring.datasource.username=your_username
spring.datasource.password=your_password
Build the Project:
mvn clean install
Run the Application:
mvn spring-boot:run
The application exposes RESTful APIs for managing User and UserProfile entities. Here are some example endpoints:
Create User:
POST /users
Get User by ID:
GET /users/{id}
Update User:
PUT /users/{id}
Delete User:
DELETE /users/{id}
src/main/java/com/example/demo: Contains the main application code.
controller: REST controllers for handling HTTP requests.model: Entity classes representing the database tables.repository: Interfaces for CRUD operations.service: Business logic and service classes.src/main/resources: Configuration files and application properties.