Skip to content

obonsignour/demo

Repository files navigation

Hibernate Demo Application

A simple Java application demonstrating Hibernate usage with PostgreSQL database.

Prerequisites

  • Java 21
  • PostgreSQL (running on port 2284)
  • Gradle (or use the included Gradle wrapper)

Database Setup

  1. Create database schema:
CREATE SCHEMA demo;
  1. Create the users table:
CREATE TABLE demo.users (
    id BIGSERIAL PRIMARY KEY,
    first_name VARCHAR(255) NOT NULL,
    last_name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL UNIQUE,
    CONSTRAINT users_email_key UNIQUE (email)
);

Configuration

  1. Create a set-env.bat file with your database credentials:
set DB_USERNAME=your_username
set DB_PASSWORD=your_password
  1. Run the environment setup:
set-env.bat

Building the Application

Using Gradle wrapper:

gradlew.bat clean build

Running the Application

gradlew.bat run

Features

  • User entity management with Hibernate
  • Demonstrates both efficient and inefficient database querying methods
  • Email uniqueness validation
  • Proper transaction management
  • Configurable logging levels

Project Structure

src/
├── main/
│   ├── java/
│   │   └── com/
│   │       └── castsoftware/
│   │           ├── Main.java
│   │           └── entity/
│   │               └── User.java
│   └── resources/
│       ├── hibernate.cfg.xml
│       ├── hibernate.properties
│       └── logback.xml

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors