Soumettre la recherche
Mettre en ligne
Ajug hibernate-dos-donts
•
Télécharger en tant que PPTX, PDF
•
2 j'aime
•
989 vues
Roy Russo
Suivre
Hibernate tips and tricks. AJUG Presentation. 2012
Lire moins
Lire la suite
Technologie
Signaler
Partager
Signaler
Partager
1 sur 28
Télécharger maintenant
Recommandé
Hibernate 18052012
Hibernate 18052012
Manisha Balwadkar
Serverless Orchestration with AWS Step Functions - DevDay Austin 2017
Serverless Orchestration with AWS Step Functions - DevDay Austin 2017
Amazon Web Services
Hibernate Basic Concepts - Presentation
Hibernate Basic Concepts - Presentation
Khoa Nguyen
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batis
day
Getting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUI
Scott Gardner
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
Jagadish Prasath
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment Platforms
Jonathan LeBlanc
HTML5 workshop, part 2
HTML5 workshop, part 2
Robert Nyman
Recommandé
Hibernate 18052012
Hibernate 18052012
Manisha Balwadkar
Serverless Orchestration with AWS Step Functions - DevDay Austin 2017
Serverless Orchestration with AWS Step Functions - DevDay Austin 2017
Amazon Web Services
Hibernate Basic Concepts - Presentation
Hibernate Basic Concepts - Presentation
Khoa Nguyen
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batis
day
Getting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUI
Scott Gardner
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
Jagadish Prasath
HTML5 Gaming Payment Platforms
HTML5 Gaming Payment Platforms
Jonathan LeBlanc
HTML5 workshop, part 2
HTML5 workshop, part 2
Robert Nyman
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
Edureka!
Hibernate 3
Hibernate 3
Rajiv Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
Arun Gupta
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
Arun Gupta
Hibernate 5 – merge() Example
Hibernate 5 – merge() Example
Ducat India
SwiftUI and Combine All the Things
SwiftUI and Combine All the Things
Scott Gardner
Daniel_Bouska_Resume
Daniel_Bouska_Resume
Daniel Bouska
InternReport
InternReport
Swetha Tanamala
Informatica Solidale - Assemblea 2014
Informatica Solidale - Assemblea 2014
Claudio Tancini
Eletrical current
Eletrical current
sandracarrijo
#Shareyouresearch - L.Benacchio
#Shareyouresearch - L.Benacchio
Master in Comunicazione delle Scienze
APC implementation on CCR Plant 2009
APC implementation on CCR Plant 2009
Pranob Banerjee
Инструкция по настройке сервиса Daas на базе мини пк
Инструкция по настройке сервиса Daas на базе мини пк
Елена Кузовкина
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
Елена Кузовкина
La membrana plasmàtica
La membrana plasmàtica
juana martinez martinez
A escola não se pode dar ao luxo de ser permissiva
A escola não se pode dar ao luxo de ser permissiva
Do outro lado da barricada
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Do outro lado da barricada
Portaria n.º 9/2017
Portaria n.º 9/2017
Do outro lado da barricada
Marcelle Poirier is a Reputed Avocat Francophone in Miami
Marcelle Poirier is a Reputed Avocat Francophone in Miami
marcellepoirier
How to generate sales leads
How to generate sales leads
Fundoodata.com
Blackwall partners 2 qtr 2016- transient volatility part iii
Blackwall partners 2 qtr 2016- transient volatility part iii
Michael Durante
Floating Point Unit (FPU)
Floating Point Unit (FPU)
Silicon Mentor
Contenu connexe
Tendances
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
Edureka!
Hibernate 3
Hibernate 3
Rajiv Gupta
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
Arun Gupta
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
Arun Gupta
Hibernate 5 – merge() Example
Hibernate 5 – merge() Example
Ducat India
SwiftUI and Combine All the Things
SwiftUI and Combine All the Things
Scott Gardner
Tendances
(6)
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
React Redux Tutorial | Redux Tutorial for Beginners | React Redux Training | ...
Hibernate 3
Hibernate 3
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: What’s New in JSR 339 ?
JAX-RS 2.0: What’s New in JSR 339 ?
Hibernate 5 – merge() Example
Hibernate 5 – merge() Example
SwiftUI and Combine All the Things
SwiftUI and Combine All the Things
En vedette
Daniel_Bouska_Resume
Daniel_Bouska_Resume
Daniel Bouska
InternReport
InternReport
Swetha Tanamala
Informatica Solidale - Assemblea 2014
Informatica Solidale - Assemblea 2014
Claudio Tancini
Eletrical current
Eletrical current
sandracarrijo
#Shareyouresearch - L.Benacchio
#Shareyouresearch - L.Benacchio
Master in Comunicazione delle Scienze
APC implementation on CCR Plant 2009
APC implementation on CCR Plant 2009
Pranob Banerjee
Инструкция по настройке сервиса Daas на базе мини пк
Инструкция по настройке сервиса Daas на базе мини пк
Елена Кузовкина
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
Елена Кузовкина
La membrana plasmàtica
La membrana plasmàtica
juana martinez martinez
A escola não se pode dar ao luxo de ser permissiva
A escola não se pode dar ao luxo de ser permissiva
Do outro lado da barricada
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Do outro lado da barricada
Portaria n.º 9/2017
Portaria n.º 9/2017
Do outro lado da barricada
Marcelle Poirier is a Reputed Avocat Francophone in Miami
Marcelle Poirier is a Reputed Avocat Francophone in Miami
marcellepoirier
How to generate sales leads
How to generate sales leads
Fundoodata.com
Blackwall partners 2 qtr 2016- transient volatility part iii
Blackwall partners 2 qtr 2016- transient volatility part iii
Michael Durante
Floating Point Unit (FPU)
Floating Point Unit (FPU)
Silicon Mentor
Arquitectura
Arquitectura
Universidad De Pamplona
Kiril mitovski-2014eng-1
Kiril mitovski-2014eng-1
Sim Aleksiev
1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotai
spa718
Risk management
Risk management
mamta bhaurya
En vedette
(20)
Daniel_Bouska_Resume
Daniel_Bouska_Resume
InternReport
InternReport
Informatica Solidale - Assemblea 2014
Informatica Solidale - Assemblea 2014
Eletrical current
Eletrical current
#Shareyouresearch - L.Benacchio
#Shareyouresearch - L.Benacchio
APC implementation on CCR Plant 2009
APC implementation on CCR Plant 2009
Инструкция по настройке сервиса Daas на базе мини пк
Инструкция по настройке сервиса Daas на базе мини пк
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
Инструкция по настройке сервиса виртуальное рабочее место на базе планшета I...
La membrana plasmàtica
La membrana plasmàtica
A escola não se pode dar ao luxo de ser permissiva
A escola não se pode dar ao luxo de ser permissiva
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Decreto lei n.º 132%2 f2012%2c de 27 de junho
Portaria n.º 9/2017
Portaria n.º 9/2017
Marcelle Poirier is a Reputed Avocat Francophone in Miami
Marcelle Poirier is a Reputed Avocat Francophone in Miami
How to generate sales leads
How to generate sales leads
Blackwall partners 2 qtr 2016- transient volatility part iii
Blackwall partners 2 qtr 2016- transient volatility part iii
Floating Point Unit (FPU)
Floating Point Unit (FPU)
Arquitectura
Arquitectura
Kiril mitovski-2014eng-1
Kiril mitovski-2014eng-1
1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotai
Risk management
Risk management
Similaire à Ajug hibernate-dos-donts
Oracle Code Event - MySQL JSON Document Store
Oracle Code Event - MySQL JSON Document Store
Mark Swarbrick
MySQL 8.0 Introduction to NoSQL + SQL
MySQL 8.0 Introduction to NoSQL + SQL
Manuel Contreras
My sql8 innodb_cluster
My sql8 innodb_cluster
Mysql User Camp
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
AmitaSuri
Dolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in Valence
Laurent Destailleur
JMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocial
Ryan Baxter
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connections Developers
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Filipe Silva
MySQL Document Store (Oracle Code Warsaw 2018)
MySQL Document Store (Oracle Code Warsaw 2018)
Vittorio Cioe
Marcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL Workbench
Women in Technology Poland
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Sven Sandberg
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
Cloud Native Day Tel Aviv
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
Rakesh Kushwaha
MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?
Olivier DASINI
Upgrading to my sql 8.0
Upgrading to my sql 8.0
Ståle Deraas
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
mfrancis
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Olivier DASINI
Sightly_techInsight
Sightly_techInsight
Purnendra Pratap Singh
Multi-tenancy with Rails
Multi-tenancy with Rails
Paul Gallagher
ServerTemplate Deep Dive
ServerTemplate Deep Dive
RightScale
Similaire à Ajug hibernate-dos-donts
(20)
Oracle Code Event - MySQL JSON Document Store
Oracle Code Event - MySQL JSON Document Store
MySQL 8.0 Introduction to NoSQL + SQL
MySQL 8.0 Introduction to NoSQL + SQL
My sql8 innodb_cluster
My sql8 innodb_cluster
Guidelines and Best Practices for Sencha Projects
Guidelines and Best Practices for Sencha Projects
Dolibarr information for developers - Christmas devcamp in Valence
Dolibarr information for developers - Christmas devcamp in Valence
JMP103 : Extending Your App Arsenal With OpenSocial
JMP103 : Extending Your App Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
IBM Connect 2014 - JMP103: Extending Your Application Arsenal With OpenSocial
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
MySQL Document Store (Oracle Code Warsaw 2018)
MySQL Document Store (Oracle Code Warsaw 2018)
Marcin Szałowicz - MySQL Workbench
Marcin Szałowicz - MySQL Workbench
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
Oracle OpenWorld 2013 - HOL9737 MySQL Replication Best Practices
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
MySQL 8.0 - What's New ?
MySQL 8.0 - What's New ?
Upgrading to my sql 8.0
Upgrading to my sql 8.0
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
MySQL Day Paris 2018 - What’s New in MySQL 8.0 ?
Sightly_techInsight
Sightly_techInsight
Multi-tenancy with Rails
Multi-tenancy with Rails
ServerTemplate Deep Dive
ServerTemplate Deep Dive
Plus de Roy Russo
Devnexus 2018
Devnexus 2018
Roy Russo
Dev nexus 2017
Dev nexus 2017
Roy Russo
Elasticsearch Atlanta Meetup 3/15/16
Elasticsearch Atlanta Meetup 3/15/16
Roy Russo
PyATL Meetup, Oct 8, 2015
PyATL Meetup, Oct 8, 2015
Roy Russo
Elasticsearch - DevNexus 2015
Elasticsearch - DevNexus 2015
Roy Russo
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
Roy Russo
ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014
Roy Russo
ElasticSearch AJUG 2013
ElasticSearch AJUG 2013
Roy Russo
Plus de Roy Russo
(8)
Devnexus 2018
Devnexus 2018
Dev nexus 2017
Dev nexus 2017
Elasticsearch Atlanta Meetup 3/15/16
Elasticsearch Atlanta Meetup 3/15/16
PyATL Meetup, Oct 8, 2015
PyATL Meetup, Oct 8, 2015
Elasticsearch - DevNexus 2015
Elasticsearch - DevNexus 2015
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch - DevNexus Atlanta - 2014
ElasticSearch AJUG 2013
ElasticSearch AJUG 2013
Dernier
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Kalema Edgar
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
Miki Katsuragi
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
Curtis Poe
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Mark Billinghurst
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
gvaughan
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Dubai Multi Commodity Centre
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
ScyllaDB
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
UiPathCommunity
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Scott Keck-Warren
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
LoriGlavin3
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
charlottematthew16
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
Sri Ambati
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Sergiu Bodiu
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Pixlogix Infotech
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Fwdays
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
Lorenzo Miniero
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Rizwan Syed
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
comworks
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
Alfredo García Lavilla
Dernier
(20)
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
Ajug hibernate-dos-donts
1.
When Hibernate Attacks! Hibernate
Best Practice and Pitfalls © 2011 Altisource Portfolio Solutions. All rights reserved. Altisource™, Altisource Portfolio Solutions™, the Altisource Logo, the "REAL" family of trademarks and service marks, and all other marks identified herein are trademarks or service marks of Altisource © 2011 S.A. or its subsidiaries and may be S.A. All with the United States Patent and Trademark Office and in other countries. Proprietary and Confidential. Portfolio Solutions Altisource Portfolio Solutionsregistered rights reserved. Proprietary and Confidential. Page | 1
2.
Agenda – Me – Hibernate
in two slides – Hibernate The Good, The Bad Sanity Check My Hibernate Divorce © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 2
3.
Me – – – – Roy Russo Former JBoss
Portal Co-Founder LoopFuse Co-Founder Senior Software Architect @ AltiSource We’re Hiring… and we don’t suck. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 3
4.
Hibernate in Two
Slides – Addresses the ‘Object-Relational Impedance Mismatch’ – Persistence classes using idiomatic Java – Transparent No interfaces or build dependencies – Querying Facilities: HQL, Criteria API, JPAQL, SQL – Database-Agnostic – Performance: Caching , Lazy initialization, fetching strategies, versioning, etc… – Automatic DDL generation © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. public class User implements Serializable { private long userid = -1; private String userName; private String firstName; private String lastName; private String password; private Map props; private Set roles; … Page | 4
5.
Hibernate in 2
Slides <hibernate-mapping> <class name="com.loopfuse.domain.auth.User" table="LF_USERS"> <id name="userid" column="USER_ID" type="java.lang.Long"> <generator class="native"/> </id> <property name="userName" column="USERNAME" type="java.lang.String" unique="true"/> … <set name="roles" table="LF_ROLE_MEMBERS" lazy="false" inverse="false" cascade="none" sort="unsorted"> <key column="USER_ID"/> <many-to-many class="com.loopfuse.domain.auth.Role" column="ROLE_ID" outer-join="true"/> </set> </class> public class User implements Serializable { private long userid; private String userName; private String firstName; private String lastName; private String password; private String email; private Map props; private Set roles; … public Task getUserByID(long ID, Session session) throws DataSourceException { Transaction tx = session.beginTransaction(); User user = null; try { Query query = session.createQuery("from User where userID=? "); query.setParameter(0, ID); user = (User) query.uniqueResult(); tx.commit(); } catch (RuntimeException e) {…} return user; } © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 5
6.
First… The Basics –
It’s JDBC – It’s a Database – (Please, work with a DBA) “Some developers come to using a tool like Hibernate because they are uncomfortable with SQL and with relational databases. We would say that this is exactly the wrong reason to use Hibernate. You should be very comfortable with SQL and JDBC before you start using Hibernate - Hibernate builds on JDBC, it does not replace it. “ Gavin King, Hibernate Founder © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 6
7.
Why we love
Hibernate – Lazy developers love Hibernate: Near-flat learning curve Little knowledge of JDBC or DB schema design Little knowledge of Hibernate mapping – Lazy loading, cache, session mgmt Little knowledge on how to tune Hibernate or its JDBC parameters Ignore Hibernate SQL Query log © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 7
8.
The Good and
the Bad – Hibernate can rock: Rapid development Cache Pooling Support / Docs – Hibernate can suck: Performance problems Session Management Development Time © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 8
9.
Problem: Schema-Ownership Development 101: 1.
Developers begin project with a clean slate. 2. Developers define schema in the DB AND *.hbm.xml 3. Developers ship product 4. DBAs held accountable for performance 5. DBAs call for refactoring / denormalization 6. Now what? – Who owns the DB schema? – Marketing called and needs 500 reports written. Who delivers? – Sales needs integration with Crystal Reports – Dual metadata: Changes to either schema requires changes in the other. (IDEs won’t refactor/migrate/adapt DB schema) © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 9
10.
Solution: Schema-Ownership, cont. –
Work with a DBA Be prepared: Likely minimize reliance on Hibernate DBA provides Query plan. – Consider Hibernate for simple CRUD – Set up a mirror DB specifically for reports Possible silo © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 10
11.
Problem: n+1 SELECT So
you set lazy=“true”… Retrieve all Items for User: Iterator items = session.createCriteria(Item.class) .add( Expression.eq("item.seller", user) ) .list() .iterator(); The n+1 problem is difficult to detect, as it is usually hidden inside application logic. Find maximum Bid for Items: List maxAmounts = new ArrayList(); while (items.hasNext()) { Item item = (Item) items.next(); BigDecimal maxAmount = new BigDecimal("0"); for ( Iterator b = item.getBids().iterator(); b.hasNext(); ) { Bid bid = (Bid) b.next(); if ( bid.getAmount().compareTo(maxAmount) == 1 ) maxAmount = bid.getAmount(); } maxAmounts.add( new MaxAmount( item.getId(), maxAmount ) ); } Hibernate issues 1 SELECT per Bid… © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 11
12.
Solution: n+1 SELECT Enable
Batch Fetching: <set name="bids" lazy="true" inverse="true" batch‐size="10"> – Hibernate pre-fetches the next 10 collections – Problem is now reduced to n/10+1 SELECTs – A little better, but now other transactions will fetch collections unnecessarily. HQL Aggregation: String query = "select MaxAmount( item.id, max(bid.amount) )" + " from Item item join fetch item.bids bid" + " where item.seller = :user group by item.id"; List maxAmounts = session.createQuery(query).setEntity("user", user).list(); – Possible solution, unless we want to do complex processing of Bids. Enable Eager Fetching: <set name="bids" inverse="true" outer‐join="true"> – Note: HQL ignores outer-join, but you can use the Criteria API – You should be fired. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 12
13.
Solution: n+1 SELECT Runtime
Declaration of Fetch Strategy: List results = session.createCriteria(Item.class) .add( Expression.eq("item.seller", user) ) .setFetchMode("bids", FetchMode.EAGER) .list(); Iterator items = new HashSet(results).iterator(); List maxAmounts = new ArrayList(); for ( ; items.hasNext(); ) { Item item = (Item) items.next(); BigDecimal maxAmount = new BigDecimal("0"); for ( Iterator b = item.getBids().iterator(); b.hasNext(); ) { Bid bid = (Bid) b.next(); if ( bid.getAmount().compareTo(maxAmount) == 1 ) maxAmount = bid.getAmount(); } maxAmounts.add( new MaxAmount( item.getId(), maxAmount ) ); } – No guarantee of distinct Items returned. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 13
14.
Problem: LazyInitializationException – Cause:
Thrown when an unitialized collection (or proxy) is accessed outside of the scope of the Session. – Detached collections can’t be initialized Lazy initialization turned on by default v3. – Recommended best practice to leave it turned on. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 14
15.
Solution: LazyInitializationException – If
Session is open, use Hibernate.initialize(item), forcing initialization, as long as the Session is open. – Keep the Session open: Open Session in View pattern: Use a servlet filter to close the Session at the end of a request. – You must alter application architecture – You must address exception handling Call Hibernate.initialize(item) in the business layer before returning to the web tier, or resort to eager fetching. May not be a feasible strategy in n-tier environments © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 15
16.
Problem: “Hibernate is
Slow” – Hibernate addresses performance: Cache Amount of data loaded – Finding the Cause: Monitor the DB – In MySQL: • • • • show processlist; log_slow_queries = /var/log/mysql/mysql-slow.log & long_query_time = 1 log-queries-not-using-indexes Monitor Hibernate logging/queries: – hibernate.show_sql=true / log4j.logger.org.hibernate.type=debug – The output will scare you, but you can use it to execute a test query… • EXPLAIN [SQL] Use a profiler © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 16
17.
Addressing: “Hibernate is
Slow” – Are tables properly indexed? Call the DBA. – Slow INSERT? Consider “batch” INSERT – Explicit flushing: • Dirty checking of objects can take a lot of time – Slow SELECT? SELECT on PK. Avoids DB call – uses cache Are you loading everything in memory and looping through it? Don’t. – 2nd Level cache on read-only entities – Use SQL ;-) – If appropriate, consider batch processing… © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 17
18.
Problem: OOM on
Batch Processing Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); } tx.commit(); session.close(); – Above code will lead to OOM Hibernate caches all newly created Customer instances © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 18
19.
Solution: OOM on
Batch Processing Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); StatelessSession session = sessionFactory.openStatelessSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close(); ScrollableResults customers = session.getNamedQuery("GetCustomers") .scroll(ScrollMode.FORWARD_ONLY); while ( customers.next() ) { Customer customer = (Customer) customers.get(0); customer.updateStuff(...); session.update(customer); } tx.commit(); session.close(); – Flush and Clear the Session regularly – Use the StatelessSession Interface Bypass cache No dirty-checking Ignores collections on entities Bypass Hibernate interceptors and event model © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 19
20.
Sanity Check – – – Addresses the
‘Object-Relational Impedance Mismatch’ Good marketing. ORM is the impedance mismatch. It creates the inefficient connection. DBs provide permanent storage. Programming languages process data in step-wide fashion. Morphing both is a mismatch. Promoting their strengths is the ideal scenario. Transparent You’re in control of the level of depth Hibernate permeates your codebase. Expect some magic. Querying Facilities (HQL, Criteria API, JPAQL, SQL) In the end, they output SQL. Ugly SQL. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 20
21.
Sanity Check – Database-Agnostic
Who cares? – “Performance”: Lazy initialization, fetching strategies, versioning, etc… Faster than what? If performance is a concern, raw JDBC/SQL is your answer. – Caching: Databases already offer this. Roll your own cache Beware of cached data modified by other applications. – Automatic DDL generation Never use this! © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 21
22.
My Hibernate Divorce –
Scenario: Analytics company processing several million hits, email clicks, email opens, and form posts per day. Over 800 customer in multi-tenant-style schema 75+ tables per schema 2 MySQL servers in Master-Slave configuration Application servers from 8GB to 16GB physical memory. – Hibernate Use: 100% Originally JSF+Hibernate = Rapid Development © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 22
23.
My Hibernate Divorce –
Problem #1: Random OOMs – Diagnosis: Boot up Jprofiler. Nothing there. Analyze heap dump file: – Hibernate holding 5MB per SessionFactory in memory, ~4GB per server Reporting and other intensive operations cause OOM By design, lazy-loading was disabled. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 23
24.
My Hibernate Divorce –
Solution: Add more RAM. Could not scale horizontally. Load balance customers across servers (ala SFDC) Rethink lazy-loading strategy: – Massive re-architecture – Suboptimal in certain parts of the system. • Recording hits/clicks/opens • Reporting Rip out Hibernate for memory intensive operations. – – – – Table per Class – this was going to take a while. Perform processing in DB, not code! That’s what they’re designed to do! Some stored proc. Get a DBA. © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 24
25.
My Hibernate Divorce –
Problem #2: Slow boot time: ~20 minutes. With hibernate update 2+ hours. (and system crashes) Marketing people aren’t patient. – Diagnosis: Hibernate SessionFactory creation across 800 schema can be slow. ;-) hbm2ddl.auto=update is evil – Solution: hbm2ddl.auto=none – Handle schema updates manually (yay, PHP!) – Migration and adapting data a manual process. Load SessionFactories on-demand. – When user logs in, load SessionFactory Reap stale SessionFactories © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 25
26.
Final Thoughts Anti-Pattern: 1. Some
repeated pattern of action, process or structure that initially appears to be beneficial, but ultimately produces more bad consequences than beneficial results, and 2. A refactored solution exists that is clearly documented, proven in actual practice and repeatable. If you really must use Hibernate: – Never let Hibernate design your schema – Your schema will outlive your application – Learn SQL, Stored Proc, and database design principles. – Proper indexing is paramount! Get a DBA. – Consider a mix: 50% Hibernate (75% or 90%) © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 26
27.
And Today… “... ‘a
lot of open source projects just outgrow Hibernate. Hibernate was great to get started and that although it has a richer set of capabilities than iBatis, sometimes it just gets in the way’.” - John Newton, CTO, Alfresco © 2011 Altisource Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 27
28.
Questions? © 2011 Altisource
Portfolio Solutions S.A. All rights reserved. Proprietary and Confidential. Page | 28
Notes de l'éditeur
http://www.hibernate.org/about/why-hibernate.html
Télécharger maintenant