13
Hibernate vs MyBatis vs JDBC: is there a silver bullet? Eugene Varfolomeev Dnepropetrovsk Tuesday, June 7, 2022

Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

April 10, 2023

Hibernate vs MyBatis vs JDBC: is there a silver bullet?

Eugene Varfolomeev

Dnepropetrovsk

Page 2: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

2 April 10, 2023

What is this presentation about?

Framework and API fundamental principles overview Features and performance comparison Applicability analysis

Page 3: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

April 10, 2023 3

Framework and API overview

Page 4: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 5: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 6: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 7: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

April 10, 2023 7

Features and Performance

Page 8: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 9: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 10: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

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

Page 11: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

11

Questions

Page 12: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

12

Page 13: Евгений Варфоломеев "Hibernate vs my batis vs jdbc: is there a silver bullet?"

April 10, 2023

Your QR Code

I am at your disposal in case of any questions or

doubts

Eugene Varfolomeev

Dnepropetrovsk

[email protected]