SlideShare a Scribd company logo
Hibernate, how the magic
is really done?
Mikalai Alimenkou/Igor Dmitriev
http://xpinjection.com
@xpinjection
Hibernate, how the magic is really done
Hibernate, how the magic is really done
Hibernate, how the magic is really done
Disclaimer
This is only my
personal experience
You could follow code samples
https://github.com/xpinjection/hibernate-basics
What Hibernate really does?
PURE MAGIC!
Demo database schema
#1. Lazy loading internals
• Persistent collections
• Lazy component/field
• Entity VS Proxy
Hibernate, how the magic is really done
#2. WHAT?!? Proxies?
• Load
• Optimized dirty checking
• Lazy loading
Hibernate, how the magic is really done
#3. What about collections?
• Collections affect performance
• All relations are lazy by default
• Some works not like you expect
• Merging values is always a pain
• Extra laziness is available
Hibernate, how the magic is really done
#4. But what was changed?
• Dirty checking is applied:
– Default approach based on
properties with reflection
– Optimized with bytecode
instrumentation
– Manual with
SelfDirtyCheckingEntity
Hibernate, how the magic is really done
#5. But when real queries run?
• Predefined order of queries is applied
– inserts
– updates
– deletions of collections elements
– inserts of the collection elements
– deletes
• Flush mode AUTO tries to be “smart”
Hibernate, how the magic is really done
Hibernate, how the magic is really done
@xpinjection
http://xpinjection.com
mikalai.alimenkou@xpinjection.com
ihor.dmitriiev@gmail.com

More Related Content

What's hot (20)

PPTX
Protractor training
Sergiy Stotskiy
 
PPTX
Brace yourself from automation death trap
Prasad Kalgutkar
 
PPTX
Saving Time By Testing With Jest
Ben McCormick
 
PDF
Thinking in React
Xcat Liu
 
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
Kasun Kodagoda
 
PPTX
Design patterns in web testing automation with WebDriver
Mikalai Alimenkou
 
PPTX
Node.js Dublin Meetup April 2014
Damian Beresford
 
PDF
Better Page Object Handling with Loadable Component Pattern
Sargis Sargsyan
 
PDF
Drupal 7 ci and testing
Claudio Beatrice
 
PPTX
Api testing libraries using java script an overview
vodQA
 
PPTX
SenchaCon 2016: Being Productive with the New Sencha Fiddle - Mitchell Simoens
Sencha
 
PDF
Sharing the pain using Protractor
Anand Bagmar
 
PPTX
Single Page Applications: Your Browser is the OS!
Jeremy Likness
 
PPT
Optimizing Java Performance
Konstantin Pavlov
 
ZIP
Five Easy Ways to QA Your Drupal Site
Mediacurrent
 
PDF
Validation for APIs in Laravel 4
Kirk Bushell
 
PPTX
anatomy of a crash
Valerie Forrestal
 
PPTX
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
PPTX
Salesforce lwc development workshops session #6
Rahul Gawale
 
PDF
akka-scalaphx-jun2015
Terry Drozdowski
 
Protractor training
Sergiy Stotskiy
 
Brace yourself from automation death trap
Prasad Kalgutkar
 
Saving Time By Testing With Jest
Ben McCormick
 
Thinking in React
Xcat Liu
 
Better End-to-End Testing with Page Objects Model using Protractor
Kasun Kodagoda
 
Design patterns in web testing automation with WebDriver
Mikalai Alimenkou
 
Node.js Dublin Meetup April 2014
Damian Beresford
 
Better Page Object Handling with Loadable Component Pattern
Sargis Sargsyan
 
Drupal 7 ci and testing
Claudio Beatrice
 
Api testing libraries using java script an overview
vodQA
 
SenchaCon 2016: Being Productive with the New Sencha Fiddle - Mitchell Simoens
Sencha
 
Sharing the pain using Protractor
Anand Bagmar
 
Single Page Applications: Your Browser is the OS!
Jeremy Likness
 
Optimizing Java Performance
Konstantin Pavlov
 
Five Easy Ways to QA Your Drupal Site
Mediacurrent
 
Validation for APIs in Laravel 4
Kirk Bushell
 
anatomy of a crash
Valerie Forrestal
 
Advanced AngularJS Tips and Tricks
Jeremy Likness
 
Salesforce lwc development workshops session #6
Rahul Gawale
 
akka-scalaphx-jun2015
Terry Drozdowski
 

Viewers also liked (20)

PDF
JEEConf. Vanilla java
Dmitriy Dumanskiy
 
PPTX
Code review at large scale
Mikalai Alimenkou
 
PDF
Counter Wars (JEEConf 2016)
Alexey Fyodorov
 
PPTX
Code generation with javac plugin
Oleksandr Radchykov
 
PPTX
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
Yaroslav Yermilov
 
PDF
Hot and spicy Java with Lombok. Live!
Vladimir Tsukur
 
PPTX
Get along with JHipster
Dmytro Panin
 
PPTX
Implement your own profiler with blackjack and fun
Vladimir Sitnikov
 
PPTX
Search and analyze your data with elasticsearch
Anton Udovychenko
 
PDF
Angular2 Development for Java developers
Yakov Fain
 
PPTX
A step-by-step approach toward high quality OutOfMemoryError analysis
Vladimir Sitnikov
 
PDF
Reactive Thinking in Java
Yakov Fain
 
PPTX
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
PDF
ORM is a perfect anti-pattern
Yegor Bugayenko
 
PPTX
How QA engineers could affect quality?
Mikalai Alimenkou
 
PPTX
Hazelcast and MongoDB at Cloud CMS
uzquiano
 
PDF
Phoenix for Rubyists
Mike North
 
PDF
Async Gateway или Разработка системы распределенных вычислений с нуля
Vitebsk Miniq
 
PPT
HighLoad++ 2009 In-Memory Data Grids
Alexey Kharlamov
 
PDF
50 nouvelles choses que l'on peut faire en Java 8
José Paumard
 
JEEConf. Vanilla java
Dmitriy Dumanskiy
 
Code review at large scale
Mikalai Alimenkou
 
Counter Wars (JEEConf 2016)
Alexey Fyodorov
 
Code generation with javac plugin
Oleksandr Radchykov
 
What Mr. Spock would possibly say about modern unit testing: pragmatic and em...
Yaroslav Yermilov
 
Hot and spicy Java with Lombok. Live!
Vladimir Tsukur
 
Get along with JHipster
Dmytro Panin
 
Implement your own profiler with blackjack and fun
Vladimir Sitnikov
 
Search and analyze your data with elasticsearch
Anton Udovychenko
 
Angular2 Development for Java developers
Yakov Fain
 
A step-by-step approach toward high quality OutOfMemoryError analysis
Vladimir Sitnikov
 
Reactive Thinking in Java
Yakov Fain
 
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
ORM is a perfect anti-pattern
Yegor Bugayenko
 
How QA engineers could affect quality?
Mikalai Alimenkou
 
Hazelcast and MongoDB at Cloud CMS
uzquiano
 
Phoenix for Rubyists
Mike North
 
Async Gateway или Разработка системы распределенных вычислений с нуля
Vitebsk Miniq
 
HighLoad++ 2009 In-Memory Data Grids
Alexey Kharlamov
 
50 nouvelles choses que l'on peut faire en Java 8
José Paumard
 
Ad

Similar to Hibernate, how the magic is really done (20)

PDF
Hibernate notesforprofessionals
Right
 
PDF
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ortus Solutions, Corp
 
PPTX
Why Do I Hate Hibernate?
Mikalai Alimenkou
 
PPTX
Why do I hate Hibernate?
Mikalai Alimenkou
 
PDF
Hibernate ORM: Tips, Tricks, and Performance Techniques
Brett Meyer
 
PPTX
Hibernate in XPages
Toby Samples
 
PDF
ITB2017 - Slaying the ORM dragons with cborm
Ortus Solutions, Corp
 
PDF
Advance Features of Hibernate
Mindfire Solutions
 
PPSX
Hibernate - Part 1
Hitesh-Java
 
PDF
Luis Majano The Battlefield ORM
Ortus Solutions, Corp
 
PPT
Hibernate
Shaharyar khan
 
PDF
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Satya Johnny
 
PDF
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Satya Johnny
 
PPSX
Hibernate - Part 2
Hitesh-Java
 
PPTX
Session 39 - Hibernate - Part 1
PawanMM
 
PPT
Hibernate for Beginners
Ramesh Kumar
 
PPT
Hibernate Session 1
b_kathir
 
PPT
Hibernate
Murali Pachiyappan
 
DOC
Hibernate tutorial for beginners
Rahul Jain
 
Hibernate notesforprofessionals
Right
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ortus Solutions, Corp
 
Why Do I Hate Hibernate?
Mikalai Alimenkou
 
Why do I hate Hibernate?
Mikalai Alimenkou
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Brett Meyer
 
Hibernate in XPages
Toby Samples
 
ITB2017 - Slaying the ORM dragons with cborm
Ortus Solutions, Corp
 
Advance Features of Hibernate
Mindfire Solutions
 
Hibernate - Part 1
Hitesh-Java
 
Luis Majano The Battlefield ORM
Ortus Solutions, Corp
 
Hibernate
Shaharyar khan
 
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Satya Johnny
 
Hibernate complete notes_by_sekhar_sir_javabynatara_j
Satya Johnny
 
Hibernate - Part 2
Hitesh-Java
 
Session 39 - Hibernate - Part 1
PawanMM
 
Hibernate for Beginners
Ramesh Kumar
 
Hibernate Session 1
b_kathir
 
Hibernate tutorial for beginners
Rahul Jain
 
Ad

More from Mikalai Alimenkou (20)

PPTX
Rise and fall of Story Points. Capacity based planning from the trenches.
Mikalai Alimenkou
 
PPTX
Static analysis tools as the best friend of QA
Mikalai Alimenkou
 
PPTX
Modern CI/CD in the microservices world with Kubernetes
Mikalai Alimenkou
 
PPTX
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
PPTX
Effectiveness tips from Kubernetes trenches by Captain Obvious
Mikalai Alimenkou
 
PPTX
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
PPTX
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
PPTX
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape ...
Mikalai Alimenkou
 
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape
Mikalai Alimenkou
 
PDF
Практические трудности в разработке Медкарты для целой страны
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Mikalai Alimenkou
 
PPTX
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
PPTX
Agile antipatterns: review after 10 years of practice
Mikalai Alimenkou
 
PPTX
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
PPTX
Bro, manage test data like a pro!
Mikalai Alimenkou
 
PPTX
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
PPTX
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
PDF
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 
Rise and fall of Story Points. Capacity based planning from the trenches.
Mikalai Alimenkou
 
Static analysis tools as the best friend of QA
Mikalai Alimenkou
 
Modern CI/CD in the microservices world with Kubernetes
Mikalai Alimenkou
 
Saga about distributed business transactions in microservices world
Mikalai Alimenkou
 
Effectiveness tips from Kubernetes trenches by Captain Obvious
Mikalai Alimenkou
 
Ride the database in JUnit tests with Database Rider
Mikalai Alimenkou
 
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
Wastful waste or why everything is so slow in development
Mikalai Alimenkou
 
DevOps checklist or how to understand where is your team in DevOps landscape ...
Mikalai Alimenkou
 
DevOps checklist or how to understand where is your team in DevOps landscape
Mikalai Alimenkou
 
Практические трудности в разработке Медкарты для целой страны
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Mikalai Alimenkou
 
Bro, manage test data like a pro! [QA Fest 2018]
Mikalai Alimenkou
 
Agile antipatterns: review after 10 years of practice
Mikalai Alimenkou
 
Hexagonal architecture with Spring Boot
Mikalai Alimenkou
 
Bro, manage test data like a pro!
Mikalai Alimenkou
 
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 

Recently uploaded (20)

PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Python basic programing language for automation
DanialHabibi2
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 

Hibernate, how the magic is really done

Editor's Notes

  • #7: TODO: поставить правильную ссылку и перегенерить QR код
  • #12: На демо показываем: запрос действительно не идет дополнительный при lazy loading для коллекции идет при доступе к ней для компонента отдельно !!! не показываем метод load возвращает не объект, а прокси и на нем дергаем получение поля, после чего идет запрос в базу
  • #14: На демо показываем: что load возвращает действительно прокси (в дебаге) на many-to-one генерируется прокси
  • #16: На демо показываем: проблему N+1 работу коллекции в extra lazy режиме указание явного JOIN в запросе или сессии !!! не показываем замена персистентной коллекции при мерже объекта извне
  • #18: На демо показываем: как работает проверка по всем сущностям и всем полям как ее отключить для запроса, транзакции, сессии (ридонли, имьютабл и StatelessSession) как включить оптимизированный вариант в Hibernate 5 как сделать ручной вариант с SelfDirtyCheckingEntity (на домашнее задание) !!! не стоит показывать
  • #20: На демо показываем: несколько запросов разного типа и потом на FLUSH их реальное выполнение в определенном порядке как не срабатывает AUTO FLUSH если выполняется SELECT NATIVE QUERY на табличку, в которую только что сделали инсерт удаление при наследовании создает темповую табличку !!! не показываем апдейт генерирует запрос на все поля даже если поменялось только одно