Upload
anna-shymchenko
View
107
Download
1
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
April 10, 2023
Hibernate vs MyBatis vs JDBC: is there a silver bullet?
Eugene Varfolomeev
Dnepropetrovsk
2 April 10, 2023
What is this presentation about?
Framework and API fundamental principles overview Features and performance comparison Applicability analysis
April 10, 2023 3
Framework and API overview
4 April 10, 2023
JDBC key points
Provides a call-level API for SQL-based database access
Oriented towards relational databases
The industry standard for database-independent connectivity
Fits well for data centric environment
5 April 10, 2023
MyBatis key points
A JDBC Framework Couples objects with
stored procedures or SQL statements
Provides a mapping engine that maps SQL parameters and results to objects in a declarative way
It is often a good choice for legacy or denormalized databases
6 April 10, 2023
Hibernate key points
A framework for mapping an object-oriented domain model to a traditional relational database
An implementation of the Java Persistence API specification
Provides wide feature range and advanced configuration abilities
Naturally fits object centric environment
April 10, 2023 7
Features and Performance
8 April 10, 2023
Benefits & overheads
Criteria JDBC MyBatis Hibernate
Learning curve
Simple to learn Simple to learn Many aspects to learn
Work in data centric env
Good, mapping efforts exist
Naturally fits Mapping issues, low performance
Work in obj centric env
Major mapping efforts
Good, limited feature amount
Naturally fits
Object mapping
Manual, hard to support
Maps methods to statements
Transparent persistence
Query language
Native SQL Native SQL HQL, Native SQL, Criteria API
Caching Poor, manual or 3rd party
Good customization
3 level, advanced customization
Locking Manual or 3rd party
Manual or 3rd party Out of the box support
9
Performance tests
Test JDBC MyBatis Hibernate
Read 5K Employees
0.51 0.77 8.09
Create and Insert 10 Employees
0.73 0.9 0.67
Update 10 Employees
0.58 0.55 0.7
Update 10 Employee Addresses
0.28 0.2 0.41
Cascade delete of 10 Employees
2.25 0.71 0.79
10
Good to keep in mind When JDBC is good to use:
– Environment is data centric
– Performance critical sections
– Complex queries that return simple results When MyBatis is good to use:
– Environment is data centric
– Development time is essential
– Entities are unclear/complex/compound
– Logic contained in stored procedures
– SQL queries need to be fine-tuned When Hibernate is good to use:
– Environment is object centric
– Domain entities are clear and stable
– Variety of CRUD operations required
– Advanced cache support required
11
Questions
12
April 10, 2023
Your QR Code
I am at your disposal in case of any questions or
doubts
Eugene Varfolomeev
Dnepropetrovsk