S01L08 – Hibernate CURD operation – Create


Hibernate CRUD Operations – “Create” in Action

Table of Contents

Introduction

CRUD stands for:

  • Create – Add new records.
  • Read – Retrieve existing data.
  • Update – Modify data.
  • Delete – Remove records.

This article focuses on the “Create Operation” in Hibernate.

CRUD Table

CRUD Operation Purpose Example
Create Add new records Insert user data
Read Fetch existing records Retrieve user info
Update Modify records Update email
Delete Remove records Delete account

Understanding the “Create” Operation

Core Components of Hibernate:

  • Session – Interface to interact with the database.
  • Transaction – Manages consistency.
  • Entity – Java class mapped to a database table.

Basic Syntax

Setting Up the Environment

1. Hibernate Configuration

2. Entity Class: Users.java

3. Main Application: App.java

Implementation of “Create” Operation

When executed, the program outputs:

Database Table:

ID Name Email
1 John Doe [email protected]

Comparison Table

Operation Method Action
Create session.save() Adds data
Update session.update() Modifies data
Read session.get() Fetches data
Delete session.delete() Removes data

Conclusion

We learned how to implement the “Create Operation” in Hibernate using Java. By following the steps above, developers can easily insert new records into the database.