SlideShare a Scribd company logo
1 of 19
Download to read offline
HIBERNATE VS. IBATIS
OR TWO WAYS OF DATABASE ACCESS




BOŠTJAN DOLENC, MARAND INŽENIRING
WHAT WE'RE ABOUT TO SEE:

  •   A bit about relevancy
  •   The ORM way (with Hibernate examples)
  •   The JDBC+ way (with iBatis examples)
  •   Problems
  •   Crossing the chasm
  •   Discussion (time permitting)
RELEVANCY

 • Data matters more than code
 • JDBC sucks
     – Aimde at system development
     – Lacks higher level features: statement
       manipulation, encapsulation, caching
     – Cumbersome use
 • Objects ≠ Relations (holy war)
ORM WAY

 • Object/class centric approach
 • Strict Object-Relational Mapping
   or
   “I hate bloody SQL”
 • Using Hibernate 3.x (and JDK <1.5)
ORM EXAMPLE
ORM EXAMPLE - CONTINUED
JDBC+ WAY

 • SQL centric approach
 • Improved JDBC
   or
   “Ad-hoc queries without JDBC horrors”
JDBC+ EXAMPLE
JDBC+ EXAMPLE - CONTINUED
ORM PROBLEM: 1+N FETCHING


 1
 2
                   10       1
                   11       1
                                42   10
                   12       1
                                43   11
                   13       2
                                44   11   22    42
                                45   12   23    42
                                46   13   ...   ...
ORM PROBLEM: 1+N FETCHING - CONTINUED

  • Eager loading to the rescue:
     – Next-level-only fails in deep hierarchies
     – All-levels fails when accessing only top-level
  • HQL to the rescue:
     – from Customer c
         join c.contracts co
         join co.bundles b
         join b.services s
ORM PROBLEM: MASSIVE UPDATES

                          for (ServiceTimeline st : services)
                          {
                            if (st.getValidTo() == null)
     1   1.1.               {
                              st.setValidTo(newDate);
     2   1.2.     1.12.
                            }
     3   15.10.           }
     4   1.2.

     5   1.1      1.12.   update service_timeline set valid_to =
                          #newDate# where valid_to is null
OTHER ORM PROBLEMS:

 • xQL (HQL, JP QL) ≠ SQL
     – Tools
     – Limited to programmers
 • POJOs sometimes aren’t Plain and Old
     – Common base class, proxies, code
       generation, annotations...
     – Build/startup overhead, subtle reflection bugs
JDBC+ PROBLEM: LOTS OF WORK FOR SIMPLE THINGS
JDBC+ PROBLEM: LOTS OF WORK FOR SIMPLE THINGS - CONTINUED
JDBC+ PROBLEM: MANUAL SAVING (INSERT/UPDATE) IS TEDIOUS


 1
               1
 2
                    10     1        2

                    11     1                         3
                                        42   10
                    12     1
                                        43   11      4
                    13     2
                                        44   11      5    22    42
                                        45   12           23    42
                                        46   13           ...   ...
OTHER JDBC+ PROBLEMS:

 • Limited caching
     – Caches only query results (by definition)
     – ORM can “understand” mutations, JDBC+
       can’t
 • Fear of SQL
     – People problem
     – Training and tools help a lot
MIX APPROACHES TO CROSS THE CHASM:

  From ORM toward JDBC+              From JDBC+ toward ORM

  • Eager flushing                   • Save phase at the end
  • HQL, SQL queries                 • Get-by-id, update, insert,
                                       delete for each class
  • Form-based / non-generic         • Active Record-like DAOs,
    development                        reflection + dynamic SQL
  • Discipline, examine the          • Custom development
    inner workings
CONCLUSION

 • The ORM-SQL chasm might be scary
 • It’s not that wide
 • You can stay in the middle with some
   tricks

More Related Content

Viewers also liked (6)

Struts presentation
Struts presentationStruts presentation
Struts presentation
 
Struts introduction
Struts introductionStruts introduction
Struts introduction
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 
WebLogic Deployment Plan Example
WebLogic Deployment Plan ExampleWebLogic Deployment Plan Example
WebLogic Deployment Plan Example
 
Introducing Swagger
Introducing SwaggerIntroducing Swagger
Introducing Swagger
 

Similar to [Dolenc] Hibernate vs. iBatis

Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
deimos
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
Steve Lange
 
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLSTROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
stmgonzalezro
 

Similar to [Dolenc] Hibernate vs. iBatis (20)

Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
 
Introducing LCS to Digital Design Verification
Introducing LCS to Digital Design VerificationIntroducing LCS to Digital Design Verification
Introducing LCS to Digital Design Verification
 
Redis ndc2013
Redis ndc2013Redis ndc2013
Redis ndc2013
 
BADCamp 2008 DB Sync
BADCamp 2008 DB SyncBADCamp 2008 DB Sync
BADCamp 2008 DB Sync
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
 
Nagios Conference 2012 - Mike Weber - disaster
Nagios Conference 2012 - Mike Weber - disasterNagios Conference 2012 - Mike Weber - disaster
Nagios Conference 2012 - Mike Weber - disaster
 
Shared Database Concurrency
Shared Database ConcurrencyShared Database Concurrency
Shared Database Concurrency
 
Monitoring and troubleshooting a glideinWMS-based HTCondor pool
Monitoring and troubleshooting a glideinWMS-based HTCondor poolMonitoring and troubleshooting a glideinWMS-based HTCondor pool
Monitoring and troubleshooting a glideinWMS-based HTCondor pool
 
Stop (de)bugging me - ICON UK 2013
Stop (de)bugging me - ICON UK 2013Stop (de)bugging me - ICON UK 2013
Stop (de)bugging me - ICON UK 2013
 
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
PHX - Session #2 Test Driven Development: Improving .NET Application Performa...
 
Coredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverCoredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS server
 
Five Lessons in Distributed Databases
Five Lessons  in Distributed DatabasesFive Lessons  in Distributed Databases
Five Lessons in Distributed Databases
 
Nagios Conference 2012 - Nathan Vonnahme - Monitoring the User Experience
Nagios Conference 2012 - Nathan Vonnahme - Monitoring the User ExperienceNagios Conference 2012 - Nathan Vonnahme - Monitoring the User Experience
Nagios Conference 2012 - Nathan Vonnahme - Monitoring the User Experience
 
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLSTROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
TROUBLESHOOTING ENTERPRISE GEODATABASE TOOLS
 
Advanced Deployment
Advanced DeploymentAdvanced Deployment
Advanced Deployment
 
Grokking Techtalk #37: Data intensive problem
 Grokking Techtalk #37: Data intensive problem Grokking Techtalk #37: Data intensive problem
Grokking Techtalk #37: Data intensive problem
 
Improving Operational Space Responsiveness
Improving Operational Space ResponsivenessImproving Operational Space Responsiveness
Improving Operational Space Responsiveness
 
An Hour of DB2 Tips
An Hour of DB2 TipsAn Hour of DB2 Tips
An Hour of DB2 Tips
 
Multi Core Playground
Multi Core PlaygroundMulti Core Playground
Multi Core Playground
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
 

More from javablend

[Muir] Seam 2 in practice
[Muir] Seam 2 in practice[Muir] Seam 2 in practice
[Muir] Seam 2 in practice
javablend
 
[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool
javablend
 
[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice
javablend
 
[Hajdukovic] Developing J2ME games for mobile phones
[Hajdukovic] Developing J2ME games for mobile phones[Hajdukovic] Developing J2ME games for mobile phones
[Hajdukovic] Developing J2ME games for mobile phones
javablend
 
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
javablend
 
[Turk] Going native with Tomcat
[Turk] Going native with Tomcat[Turk] Going native with Tomcat
[Turk] Going native with Tomcat
javablend
 
[Grabec] Solr - Searching made easy
[Grabec] Solr - Searching made easy[Grabec] Solr - Searching made easy
[Grabec] Solr - Searching made easy
javablend
 

More from javablend (7)

[Muir] Seam 2 in practice
[Muir] Seam 2 in practice[Muir] Seam 2 in practice
[Muir] Seam 2 in practice
 
[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool
 
[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice[Roblek] Distributed computing in practice
[Roblek] Distributed computing in practice
 
[Hajdukovic] Developing J2ME games for mobile phones
[Hajdukovic] Developing J2ME games for mobile phones[Hajdukovic] Developing J2ME games for mobile phones
[Hajdukovic] Developing J2ME games for mobile phones
 
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
[Pilarczyk] Adrenaline programing implementing - SOA and BPM in your application
 
[Turk] Going native with Tomcat
[Turk] Going native with Tomcat[Turk] Going native with Tomcat
[Turk] Going native with Tomcat
 
[Grabec] Solr - Searching made easy
[Grabec] Solr - Searching made easy[Grabec] Solr - Searching made easy
[Grabec] Solr - Searching made easy
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

[Dolenc] Hibernate vs. iBatis

  • 1. HIBERNATE VS. IBATIS OR TWO WAYS OF DATABASE ACCESS BOŠTJAN DOLENC, MARAND INŽENIRING
  • 2. WHAT WE'RE ABOUT TO SEE: • A bit about relevancy • The ORM way (with Hibernate examples) • The JDBC+ way (with iBatis examples) • Problems • Crossing the chasm • Discussion (time permitting)
  • 3. RELEVANCY • Data matters more than code • JDBC sucks – Aimde at system development – Lacks higher level features: statement manipulation, encapsulation, caching – Cumbersome use • Objects ≠ Relations (holy war)
  • 4. ORM WAY • Object/class centric approach • Strict Object-Relational Mapping or “I hate bloody SQL” • Using Hibernate 3.x (and JDK <1.5)
  • 6. ORM EXAMPLE - CONTINUED
  • 7. JDBC+ WAY • SQL centric approach • Improved JDBC or “Ad-hoc queries without JDBC horrors”
  • 9. JDBC+ EXAMPLE - CONTINUED
  • 10. ORM PROBLEM: 1+N FETCHING 1 2 10 1 11 1 42 10 12 1 43 11 13 2 44 11 22 42 45 12 23 42 46 13 ... ...
  • 11. ORM PROBLEM: 1+N FETCHING - CONTINUED • Eager loading to the rescue: – Next-level-only fails in deep hierarchies – All-levels fails when accessing only top-level • HQL to the rescue: – from Customer c join c.contracts co join co.bundles b join b.services s
  • 12. ORM PROBLEM: MASSIVE UPDATES for (ServiceTimeline st : services) { if (st.getValidTo() == null) 1 1.1. { st.setValidTo(newDate); 2 1.2. 1.12. } 3 15.10. } 4 1.2. 5 1.1 1.12. update service_timeline set valid_to = #newDate# where valid_to is null
  • 13. OTHER ORM PROBLEMS: • xQL (HQL, JP QL) ≠ SQL – Tools – Limited to programmers • POJOs sometimes aren’t Plain and Old – Common base class, proxies, code generation, annotations... – Build/startup overhead, subtle reflection bugs
  • 14. JDBC+ PROBLEM: LOTS OF WORK FOR SIMPLE THINGS
  • 15. JDBC+ PROBLEM: LOTS OF WORK FOR SIMPLE THINGS - CONTINUED
  • 16. JDBC+ PROBLEM: MANUAL SAVING (INSERT/UPDATE) IS TEDIOUS 1 1 2 10 1 2 11 1 3 42 10 12 1 43 11 4 13 2 44 11 5 22 42 45 12 23 42 46 13 ... ...
  • 17. OTHER JDBC+ PROBLEMS: • Limited caching – Caches only query results (by definition) – ORM can “understand” mutations, JDBC+ can’t • Fear of SQL – People problem – Training and tools help a lot
  • 18. MIX APPROACHES TO CROSS THE CHASM: From ORM toward JDBC+ From JDBC+ toward ORM • Eager flushing • Save phase at the end • HQL, SQL queries • Get-by-id, update, insert, delete for each class • Form-based / non-generic • Active Record-like DAOs, development reflection + dynamic SQL • Discipline, examine the • Custom development inner workings
  • 19. CONCLUSION • The ORM-SQL chasm might be scary • It’s not that wide • You can stay in the middle with some tricks