This is a simple CRUD (Create, Read, Update, Delete) application built with Java and Hibernate ORM, using MySQL as the database. It demonstrates basic operations on a User
entity using JPA and Hibernate.
The project shows how to perform basic database operations using Hibernate ORM. It includes full examples of creating, reading, updating, and deleting data from a MySQL database.
- Java 11+
- Hibernate 5.x
- MySQL 8+
- Maven
- JPA (Java Persistence API)
- Log4j (logging)
-
Clone the repository
git clone https://github.com/vasile007/java-hibernate-crud-application.git cd java-hibernate-crud-application
-
Configure database connection
Opensrc/main/resources/hibernate.cfg.xml
and set your database credentials:<property name="connection.url">jdbc:mysql://localhost:3306/your_database</property> <property name="connection.username">your_username</property> <property name="connection.password">your_password</property>
-
Build the project
mvn clean install
-
Run the application
Run theMain.java
class from your IDE or terminal.
This project manages a simple User
entity with fields such as id
, name
, and email
. All CRUD operations are implemented in a UserDAO
class.
// Create
User user = new User("John Doe", "john@example.com");
userDao.saveUser(user);
// Read
User retrieved = userDao.getUserById(1);
// Update
retrieved.setName("Jane Doe");
userDao.updateUser(retrieved);
// Delete
userDao.deleteUserById(1);
🤝 Contributing Contributions are welcome! Here's how to contribute:
-
Fork the repository
-
Create a new branch: git checkout -b feature-name
-
Commit your changes: git commit -m 'Add feature'
-
Push to your branch: git push origin feature-name
-
Open a Pull Request
🛡️ License This project is licensed under the MIT License. See the LICENSE file for details.
📧 Contact Thank you and feel free to open an issue or contact me at: bejan.vasi@yahoo.com