직접 hibernate 를 가볍게 구현해봅니다.

Overview

Roach 의 Hibernate 간단 구조

목적

Hibernate 의 코드를 실제로 까보는 사람도 많지 않을뿐더러, 그 안의 원리구조를 이해하는 것 또한 힘들다고 생각합니다.
그래서 가볍게 읽기 좋은 방식으로 Hibernate 내부의 Event-Driven 구조 그리고 DirtyChecking 등에 대해서 적어보려고 합니다.
간략하게 생략하는 부분이 많다보니 추상적인 부분은 비슷하나, 디테일한 내용은 다를수 있습니다. 이해바랍니다.

Event-Driven

기본적으로 Persist 가 발생하면 PersistEvent 가 발생합니다.
PersistEvent 는 EntityId, Entity 정보를 담고 있고 이미 영속화된 객체일 경우 Dirty-Checking 을 진행합니다.
Dirty-Checking 간 변경점 발생시 실제 물리적 저장소에 UPDATE Query 가 실행됩니다.

배울 수 있는 부분

  • Hibernate 는 Entity 의 특정 변경, 영속 등의 Event 를 발행하여 관리함을 알 수 있습니다.
  • Dirty-Checking 이 Entity 의 변경점을 변경하는 것을 알 수 있습니다.
    • 변경 여부만 확인하고 그대로 UPDATE QUERY 를 만드므로 특정 변경점만 UPDATE QUERY 로 나가지 않음을 알 수 있습니다.(? 이건 사실 내 코드로는 알 수 있을까 싶기도..)

아직 구현안된 부분

  • Session
    • 어떻게 구현할지 고민중.. 그냥 Config Class 로 둘까도 고민중이다.
    • Session.MANUAL_MODE => Dirty-Checking 안하는 부분 구현. 사실 session.flush() 도 구현해야 되는데 흐음.

구현 안할 부분

  • 실제 물리적 저장소에 붙을 마음은 없음. 그러면 일이 너무 커짐, 진짜 ORM 을 만들어야 함.
You might also like...

This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

Nov 2, 2021

A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture.

Snap-Snippet A code sharing platform built using spring boot, hibernate and JPA as ORM with PostgreSQL which also follows a RESTful architecture. Tech

Nov 29, 2022

Um sistema de hospital feito em Spring Boot, contendo alguns CRUD's, e utilizando algumas famosas dependências, como o Hibernate. Vale destacar a interface inspirada no jogo Minecraft.

Um sistema de hospital feito em Spring Boot, contendo alguns CRUD's, e utilizando algumas famosas dependências, como o Hibernate. Vale destacar a interface inspirada no jogo Minecraft.

Introdução ✏ Esse projeto é uma atividade da disciplina de Design, Arquitetura e Construção de Software [DACS]. O objetivo do projeto é simular um sis

Nov 6, 2022

Applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, Paging & Sorting, various Relationships, Transactions

Applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, Paging & Sorting, various Relationships, Transactions

University Management In this project, I practiced & applied Spring Data JPA technologies including mapping, connecting real DB, Hibernate, Queries, P

Sep 5, 2022

A simple quarkus app with hibernate as ORM, used to show the features of Hibernate Search

beer-manager-hibernate-search Project This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, ple

Jan 6, 2022

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper

Simple Flat Mapper Release Notes Getting Started Docs Building it The build is using Maven. git clone https://github.com/arnaudroger/SimpleFlatMapper.

Dec 17, 2022

Dynamically filters JPA entities with a simple query syntax. Provides JPA/Hibernate predicates and Spring Data specifications.

Spring Filter You need a way to dynamically filter entities without any effort? Just add me to your pom.xml. Your API will gain a full featured search

Dec 13, 2022

hibernate redis 二级缓存使用 spring boot redis 配置

hibernate-redisson-spring-boot-starter 介绍 使用 Redisson 作为 hibernate redis 二级缓存提供器,redisson-hibernate-53(hibernate-version) 无法使用 spring boot 配置文件创建的 org

Jul 3, 2022

Spring Boot, Hibernate, JpaRepository, RESTful services & PostgreSQL.

Spring Boot, Hibernate, JpaRepository, RESTful services & PostgreSQL.

HRMS-Project Human Resources Management System Back End application with Java, Spring Boot, Hibernate, JpaRepository, RESTful services & PostgreSQL. S

Aug 23, 2022

Multi-Tenant Spring Boot Application with separate databases using Hibernate and H2.

Multi-Tenant Spring Boot Application A Spring Boot application that utilises a multi-tenancy architecture by providing multiple databases, one for eac

May 9, 2022

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Tutorial for Beginners File Directory Apache Tomcat Apache Tomcat - Eclipse Bağlantısı Spring Paketlerinin İndirilmesi ve Projeye Entegrasyonu

Apr 11, 2022

Teste tcs loja REST/Endpoints/Postman/log4j/java/hibernate/H2

# Aplicativo REST API LOJA (Cliente, Produto, Pedido, Itens do Pedido) Requerimentos Para construir e executar a aplicação você precisa: JDK 11 Maven

Jul 8, 2022

Hibernate's core Object/Relational Mapping functionality

Hibernate ORM is a library providing Object/Relational Mapping (ORM) support to applications, libraries, and frameworks. It also provides an implement

Jan 9, 2023

Spring JPA, Hibernate One To Many example in Spring Boot with @ManyToOne annotation

Spring Boot One To Many example with Spring JPA, Hibernate Implement Spring JPA One-To-Many mapping with Hibernate in a Spring Boot CRUD example using

Dec 28, 2022

The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

About The Project SignIn page SignUp page Profile page The goal of the project is to create a web application using Java EE and database (PostgreSQL)

Mar 23, 2022

Efficient lazy load approach for entities containing clob in hibernate

Lazy loading clob fields of Entites using Hibernate This is an efficient approach to load clob fields lazily of an Entity. Using this approach, distin

Jan 22, 2022

A simple Project based on Jsp and Servlets and Hibernate.

A simple Project based on Jsp and Servlets and Hibernate.

Learning Management System in Java In this project, I have created a Simple Learning Management System which is based on Java server pages, Servlet &

Feb 2, 2022
Owner
roach
꾸준한 개발자
roach
Dynamically filters JPA entities with a simple query syntax. Provides JPA/Hibernate predicates and Spring Data specifications.

Spring Filter You need a way to dynamically filter entities without any effort? Just add me to your pom.xml. Your API will gain a full featured search

Turkraft 142 Dec 13, 2022
hibernate redis 二级缓存使用 spring boot redis 配置

hibernate-redisson-spring-boot-starter 介绍 使用 Redisson 作为 hibernate redis 二级缓存提供器,redisson-hibernate-53(hibernate-version) 无法使用 spring boot 配置文件创建的 org

null 4 Jul 3, 2022
Spring Boot, Hibernate, JpaRepository, RESTful services & PostgreSQL.

HRMS-Project Human Resources Management System Back End application with Java, Spring Boot, Hibernate, JpaRepository, RESTful services & PostgreSQL. S

Hikmet Tutuncu 9 Aug 23, 2022
Multi-Tenant Spring Boot Application with separate databases using Hibernate and H2.

Multi-Tenant Spring Boot Application A Spring Boot application that utilises a multi-tenancy architecture by providing multiple databases, one for eac

Alex Gschnitzer 15 May 9, 2022
Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Tutorial for Beginners File Directory Apache Tomcat Apache Tomcat - Eclipse Bağlantısı Spring Paketlerinin İndirilmesi ve Projeye Entegrasyonu

İbrahim Can Erdoğan 11 Apr 11, 2022
The goal of the project is to create a web application using Java EE and database (PostgreSQL) without connecting a modern technology stack like spring boot and hibernate

About The Project SignIn page SignUp page Profile page The goal of the project is to create a web application using Java EE and database (PostgreSQL)

Islam Khabibullin 2 Mar 23, 2022
A simple Project based on Jsp and Servlets and Hibernate.

Learning Management System in Java In this project, I have created a Simple Learning Management System which is based on Java server pages, Servlet &

Indranil Roy 1 Feb 2, 2022
Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

null 17 Dec 28, 2022
This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap

This project archetype is a template for creating a fully functional MVC web application using Hibernate, JSTL and Bootstrap. It has an automatic database creation, auto initial load of the data, with different variety of users. It also has a checkstyle to check the proper coding of your project immediately right after you enter the code.

null 90 Oct 21, 2022
This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru

Spring Data JPA - Spring Data JPA This repository contains source code examples to support my course Spring Data JPA and Hibernate Beginner to Guru Co

John Thompson 8 Aug 24, 2022