SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
/11@yegor256 1
ORM - это обидно
Егор Бугаенко
ORM is an offensive anti-pattern
/11@yegor256 2
@Entity
@Table(name = "post")
public class Post {
private int id;
private String title;
@Id
@GeneratedValue
public int getId() {
return this.id;
}
@Column(name = "title")
public Title getTitle() {
return this.title;
}
public void setTitle(String txt) {
this.title = txt;
}
}
/11@yegor256
3
MySQL
JDBC
UPDATE user

SET name = “Jeff”

WHERE id = 123
u.getName();
statement.executeUpdate();
setName() this.name = “Jeff”;
u.setName(“Jeff”);
session.update(u);
update()
User
Session
/11@yegor256 4
не объект
/11@yegor256 5
Session session = factory.openSession();
try {
Transaction txn = session.beginTransaction();
User user = query.list().get(0);
user.setName(/* the logic to test */);
session.update(user);
txn.commit();
} catch (HibernateException ex) {
txn.rollback();
} finally {
session.close();
}
/11@yegor256 6
public class LoggedUser implements User {
private final User origin;
public LoggedUser(User user) {
this.origin = user;
}
@Override
public void rename(String name) {
long start = System.currentTimeMillis();
this.origin.rename(name);
logger.debug(
“user renaming took %d ms”,
System.currentTimeMillis() - start
);
}
}
/11@yegor256 7
List posts = session.createQuery(
"FROM Post WHERE author = ‘Jeff’”
).list();
for (Post post : (List<Post>) posts){
System.out.println(
"Title: " + post.getTitle()
);
}
/11@yegor256 8
SQL-speaking объекты
/11@yegor256 9
MySQL
JDBC
UPDATE user

SET name = “Jeff”

WHERE id = 123
statement.executeUpdate();
rename()
x.update(“user”)
.set(“name”, “Jeff”)
.where(“id”, 123)
.execute();
u.rename(“Jeff”); User
jOOQ
/11@yegor256 10
public class Post {
private int id;
public int getId() {
return this.id;
}
public Title getTitle() {
return this.x.select(“title”)
.from(“post”)
.where(“id”, this.id)
.fetchOne();
}
public void setTitle(String txt) {
this.x.update(“user”)
.set(“title”, txt)
.where(“id”, this.id)
.execute();
}
}
/11@yegor256 11
www.yegor256.com

Más contenido relacionado

La actualidad más candente

Lecture6 display data by okello erick
Lecture6 display data by okello erickLecture6 display data by okello erick
Lecture6 display data by okello erickokelloerick
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
TDD in the wild
TDD in the wildTDD in the wild
TDD in the wildBrainhub
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOSMake School
 
Ext GWT 3.0 Advanced Templates
Ext GWT 3.0 Advanced TemplatesExt GWT 3.0 Advanced Templates
Ext GWT 3.0 Advanced TemplatesSencha
 
Retrieving data from database using result set (1)
Retrieving data from database using result set (1)Retrieving data from database using result set (1)
Retrieving data from database using result set (1)rishisingh190
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Kevin Octavian
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento EnterpriseTobias Zander
 
Android Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupAndroid Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupRon Shapiro
 

La actualidad más candente (16)

Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Lecture6 display data by okello erick
Lecture6 display data by okello erickLecture6 display data by okello erick
Lecture6 display data by okello erick
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
Binary tree in java
Binary tree in javaBinary tree in java
Binary tree in java
 
TDD in the wild
TDD in the wildTDD in the wild
TDD in the wild
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOS
 
Ext GWT 3.0 Advanced Templates
Ext GWT 3.0 Advanced TemplatesExt GWT 3.0 Advanced Templates
Ext GWT 3.0 Advanced Templates
 
Querydsl overview 2014
Querydsl overview 2014Querydsl overview 2014
Querydsl overview 2014
 
Retrieving data from database using result set (1)
Retrieving data from database using result set (1)Retrieving data from database using result set (1)
Retrieving data from database using result set (1)
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
Sql
SqlSql
Sql
 
Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1Windows 8 Training Fundamental - 1
Windows 8 Training Fundamental - 1
 
Solr integration in Magento Enterprise
Solr integration in Magento EnterpriseSolr integration in Magento Enterprise
Solr integration in Magento Enterprise
 
Drupal7 dbtng
Drupal7  dbtngDrupal7  dbtng
Drupal7 dbtng
 
Html web sql database
Html web sql databaseHtml web sql database
Html web sql database
 
Android Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android MeetupAndroid Cursor Utils - NYC Android Meetup
Android Cursor Utils - NYC Android Meetup
 

Destacado

Practical Example of AOP with AspectJ
Practical Example of AOP with AspectJPractical Example of AOP with AspectJ
Practical Example of AOP with AspectJYegor Bugayenko
 
ORM is a perfect anti-pattern
ORM is a perfect anti-patternORM is a perfect anti-pattern
ORM is a perfect anti-patternYegor Bugayenko
 
ORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternYegor Bugayenko
 
How Anemic Objects Kill OOP
How Anemic Objects Kill OOPHow Anemic Objects Kill OOP
How Anemic Objects Kill OOPYegor Bugayenko
 
Management without managers
Management without managersManagement without managers
Management without managersYegor Bugayenko
 
The Plain English Guide To Customer Research
The Plain English Guide To Customer ResearchThe Plain English Guide To Customer Research
The Plain English Guide To Customer ResearchORM
 
A Quick Preview of What You'll See at Qt World Summit 2016
A Quick Preview of What You'll See at Qt World Summit 2016A Quick Preview of What You'll See at Qt World Summit 2016
A Quick Preview of What You'll See at Qt World Summit 2016Qt
 
Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!Yegor Bugayenko
 
How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?Yegor Bugayenko
 
Continuous Integration is Dead
Continuous Integration is DeadContinuous Integration is Dead
Continuous Integration is DeadYegor Bugayenko
 
Fail Fast. Into User's Face.
Fail Fast. Into User's Face.Fail Fast. Into User's Face.
Fail Fast. Into User's Face.Yegor Bugayenko
 

Destacado (20)

Object Oriented Lies
Object Oriented LiesObject Oriented Lies
Object Oriented Lies
 
Practical Example of AOP with AspectJ
Practical Example of AOP with AspectJPractical Example of AOP with AspectJ
Practical Example of AOP with AspectJ
 
ORM is a perfect anti-pattern
ORM is a perfect anti-patternORM is a perfect anti-pattern
ORM is a perfect anti-pattern
 
ORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-PatternORM is an Offensive Anti-Pattern
ORM is an Offensive Anti-Pattern
 
How Anemic Objects Kill OOP
How Anemic Objects Kill OOPHow Anemic Objects Kill OOP
How Anemic Objects Kill OOP
 
Built-in Fake Objects
Built-in Fake ObjectsBuilt-in Fake Objects
Built-in Fake Objects
 
Management without managers
Management without managersManagement without managers
Management without managers
 
Chat Bot Architecture
Chat Bot ArchitectureChat Bot Architecture
Chat Bot Architecture
 
Forget The ORM!
Forget The ORM!Forget The ORM!
Forget The ORM!
 
The Plain English Guide To Customer Research
The Plain English Guide To Customer ResearchThe Plain English Guide To Customer Research
The Plain English Guide To Customer Research
 
A Quick Preview of What You'll See at Qt World Summit 2016
A Quick Preview of What You'll See at Qt World Summit 2016A Quick Preview of What You'll See at Qt World Summit 2016
A Quick Preview of What You'll See at Qt World Summit 2016
 
Orm hero
Orm heroOrm hero
Orm hero
 
Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!Need It Robust? Make It Fragile!
Need It Robust? Make It Fragile!
 
How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?How Do You Know When Your Product is Ready to be Shipped?
How Do You Know When Your Product is Ready to be Shipped?
 
OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!OOP Is Dead? Not Yet!
OOP Is Dead? Not Yet!
 
Continuous Integration is Dead
Continuous Integration is DeadContinuous Integration is Dead
Continuous Integration is Dead
 
Who Manages Who?
Who Manages Who?Who Manages Who?
Who Manages Who?
 
Meetings Or Discipline
Meetings Or DisciplineMeetings Or Discipline
Meetings Or Discipline
 
Fail Fast. Into User's Face.
Fail Fast. Into User's Face.Fail Fast. Into User's Face.
Fail Fast. Into User's Face.
 
Problems With Chat Bots
Problems With Chat BotsProblems With Chat Bots
Problems With Chat Bots
 

Similar a ORM is offensive

Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
Android Architecture - Khoa Tran
Android Architecture -  Khoa TranAndroid Architecture -  Khoa Tran
Android Architecture - Khoa TranTu Le Dinh
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Ryosuke Uchitate
 
Soundreader.classpathSoundreader.project Soundre.docx
Soundreader.classpathSoundreader.project  Soundre.docxSoundreader.classpathSoundreader.project  Soundre.docx
Soundreader.classpathSoundreader.project Soundre.docxwhitneyleman54422
 
Androidの本当にあった怖い話
Androidの本当にあった怖い話Androidの本当にあった怖い話
Androidの本当にあった怖い話Yusuke Yamamoto
 
Oracle XML Handling
Oracle XML HandlingOracle XML Handling
Oracle XML Handlingazharpro
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfdhavalbl38
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014Jan Jongboom
 
Lombokの紹介
Lombokの紹介Lombokの紹介
Lombokの紹介onozaty
 
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docximport org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docxRyanEAcTuckern
 
บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&deletePalm Unnop
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
Java → kotlin: Tests Made Simple
Java → kotlin: Tests Made SimpleJava → kotlin: Tests Made Simple
Java → kotlin: Tests Made Simpleleonsabr
 

Similar a ORM is offensive (17)

Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Android Architecture - Khoa Tran
Android Architecture -  Khoa TranAndroid Architecture -  Khoa Tran
Android Architecture - Khoa Tran
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
 
Soundreader.classpathSoundreader.project Soundre.docx
Soundreader.classpathSoundreader.project  Soundre.docxSoundreader.classpathSoundreader.project  Soundre.docx
Soundreader.classpathSoundreader.project Soundre.docx
 
Androidの本当にあった怖い話
Androidの本当にあった怖い話Androidの本当にあった怖い話
Androidの本当にあった怖い話
 
Oracle XML Handling
Oracle XML HandlingOracle XML Handling
Oracle XML Handling
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdf
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
 
ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014ESNext for humans - LvivJS 16 August 2014
ESNext for humans - LvivJS 16 August 2014
 
Lombokの紹介
Lombokの紹介Lombokの紹介
Lombokの紹介
 
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docximport org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
 
บทที่6 update&delete
บทที่6 update&deleteบทที่6 update&delete
บทที่6 update&delete
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
Java → kotlin: Tests Made Simple
Java → kotlin: Tests Made SimpleJava → kotlin: Tests Made Simple
Java → kotlin: Tests Made Simple
 

Más de Yegor Bugayenko

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Yegor Bugayenko
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Yegor Bugayenko
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)Yegor Bugayenko
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 InterviewsYegor Bugayenko
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Yegor Bugayenko
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. TestingYegor Bugayenko
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in TestingYegor Bugayenko
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing PitfallsYegor Bugayenko
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid OfYegor Bugayenko
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?Yegor Bugayenko
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainYegor Bugayenko
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolYegor Bugayenko
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaYegor Bugayenko
 

Más de Yegor Bugayenko (20)

Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?Can Distributed Teams Deliver Quality?
Can Distributed Teams Deliver Quality?
 
Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?Are You Sure You Are Not a Micromanager?
Are You Sure You Are Not a Micromanager?
 
On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)On Requirements Management (Demotivate Them Right)
On Requirements Management (Demotivate Them Right)
 
My Experience of 1000 Interviews
My Experience of 1000 InterviewsMy Experience of 1000 Interviews
My Experience of 1000 Interviews
 
Are you sure you are not a micromanager?
Are you sure you are not a micromanager?Are you sure you are not a micromanager?
Are you sure you are not a micromanager?
 
Quality Assurance vs. Testing
Quality Assurance vs. TestingQuality Assurance vs. Testing
Quality Assurance vs. Testing
 
Is Java Getting Better?
Is Java Getting Better?Is Java Getting Better?
Is Java Getting Better?
 
Typical Pitfalls in Testing
Typical Pitfalls in TestingTypical Pitfalls in Testing
Typical Pitfalls in Testing
 
Software Testing Pitfalls
Software Testing PitfallsSoftware Testing Pitfalls
Software Testing Pitfalls
 
Five Trends We Are Afraid Of
Five Trends We Are Afraid OfFive Trends We Are Afraid Of
Five Trends We Are Afraid Of
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Who Cares About Quality?
Who Cares About Quality?Who Cares About Quality?
Who Cares About Quality?
 
Quantity vs. Quality
Quantity vs. QualityQuantity vs. Quality
Quantity vs. Quality
 
Experts vs Expertise
Experts vs ExpertiseExperts vs Expertise
Experts vs Expertise
 
Zold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without BlockchainZold: a cryptocurrency without Blockchain
Zold: a cryptocurrency without Blockchain
 
Life Without Blockchain
Life Without BlockchainLife Without Blockchain
Life Without Blockchain
 
How to Cut Corners and Stay Cool
How to Cut Corners and Stay CoolHow to Cut Corners and Stay Cool
How to Cut Corners and Stay Cool
 
Math or Love?
Math or Love?Math or Love?
Math or Love?
 
How much do you cost?
How much do you cost?How much do you cost?
How much do you cost?
 
Java Annotations Are a Bad Idea
Java Annotations Are a Bad IdeaJava Annotations Are a Bad Idea
Java Annotations Are a Bad Idea
 

Último

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Último (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

ORM is offensive

  • 1. /11@yegor256 1 ORM - это обидно Егор Бугаенко ORM is an offensive anti-pattern
  • 2. /11@yegor256 2 @Entity @Table(name = "post") public class Post { private int id; private String title; @Id @GeneratedValue public int getId() { return this.id; } @Column(name = "title") public Title getTitle() { return this.title; } public void setTitle(String txt) { this.title = txt; } }
  • 3. /11@yegor256 3 MySQL JDBC UPDATE user
 SET name = “Jeff”
 WHERE id = 123 u.getName(); statement.executeUpdate(); setName() this.name = “Jeff”; u.setName(“Jeff”); session.update(u); update() User Session
  • 5. /11@yegor256 5 Session session = factory.openSession(); try { Transaction txn = session.beginTransaction(); User user = query.list().get(0); user.setName(/* the logic to test */); session.update(user); txn.commit(); } catch (HibernateException ex) { txn.rollback(); } finally { session.close(); }
  • 6. /11@yegor256 6 public class LoggedUser implements User { private final User origin; public LoggedUser(User user) { this.origin = user; } @Override public void rename(String name) { long start = System.currentTimeMillis(); this.origin.rename(name); logger.debug( “user renaming took %d ms”, System.currentTimeMillis() - start ); } }
  • 7. /11@yegor256 7 List posts = session.createQuery( "FROM Post WHERE author = ‘Jeff’” ).list(); for (Post post : (List<Post>) posts){ System.out.println( "Title: " + post.getTitle() ); }
  • 9. /11@yegor256 9 MySQL JDBC UPDATE user
 SET name = “Jeff”
 WHERE id = 123 statement.executeUpdate(); rename() x.update(“user”) .set(“name”, “Jeff”) .where(“id”, 123) .execute(); u.rename(“Jeff”); User jOOQ
  • 10. /11@yegor256 10 public class Post { private int id; public int getId() { return this.id; } public Title getTitle() { return this.x.select(“title”) .from(“post”) .where(“id”, this.id) .fetchOne(); } public void setTitle(String txt) { this.x.update(“user”) .set(“title”, txt) .where(“id”, this.id) .execute(); } }