Hibernate Architecture: Complete Overview

Explanation of the Hibernate Codebase

1. Project Structure and Maven Configuration

The project follows a standard Maven directory structure with a separation of concerns:

The pom.xml file:

2. Hibernate Configuration

The hibernate.cfg.xml file in the resources folder is crucial for configuring Hibernate:

<hibernate-configuration>
    <session-factory>
        <!-- Database connection settings -->
        <property name="hibernate.connection.autocommit">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/adv_java?createDatabaseIfNotExist=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true</property>
        <property name="hibernate.connection.username">root</property>

        <!-- SQL dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

        <!-- Session management -->
        <property name="hibernate.current_session_context_class">thread</property>

        <!-- Connection pooling -->
        <property name="hibernate.connection.pool_size">10</property>

        <!-- Echo SQL to stdout -->
        <property name="hibernate.show_sql">true</property>

        <!-- Database schema auto-update -->
        <property name="hibernate.hbm2ddl.auto">update</property>

        <!-- Entity mapping -->
        <mapping class="com.sunbeam.entities.User"/>
    </session-factory>
</hibernate-configuration>

Key annotations: