Download - ORM, JPA, & Hibernate Overview
PowerPoint Presentation
Hibernate ORM
& JPA Overview
Brett MeyerSenior Software EngineerHibernate ORM, Red Hat
Brett Meyer
JBoss Overlord (SOA Governance)
Hibernate ORMORM 4 & 5 development
Hibernate OSGi
Developer community engagement
Red Hat support, Hibernate engineering lead
Other contributionsApache Camel
Infinispan
Contact me@brettemeyer or +brettmeyer
Freenode IRC: brmeyer
github.com/brmeyer
/HibernateDemos
slideshare.net/brmeyer
ORM? JPA?
ORM: Object/Relational Mapping
JPA: Java Persistence API
Hibernate ORM provides its own native API, in addition to full JPA support
Annotations and XML
Overview
JDBC
Why ORM?
Why JPA?
Hibernate ORM
Demos
JDBC
JDBC
Java Database Connectivity
Java SE library for querying/updating database data
Mainly focused on relational DBs
Manages Connections to the DB, either directly or through a 3rd party Connection Pool
Database vendors provide their own JDBC driver libraries
JDBC (cont'd)
API abstracts common interactions, data types, etc.
Execute SQL through Statements
Query returns received through ResultSets
Transactional
Cacheable
JDBC Demo
Why ORM?
ORM
Object/Relational Mapping
Persistence: Data objects outlive the JVM app
Maps Java POJOs to relational databases (one type of persistence)
Why ORM?
Domain Model patternFocus on business concepts, not relational DB structure
Interconnected objects
Each object is a meaningful individual/concept
OO concepts: inheritance, object identity, etc.
Navigate data by walking the object graph, not the explicit relational model
Why ORM? (cont'd)
Increased development speed & reduced codeNo by-hand mapping of JDBC ResultSets to POJOs
Less work synchronizing code with relational DB changes
Less JBDC boilerplate (repetitious CRUD)
Focus on business logic
Why ORM? (cont'd)
PortabilityMostly DB independent (exception: some types of features, identifier generation, etc.)
Query abstractions (OO APIs, OO-structured languages, etc.)
Vendor-specific SQL is auto generated
Why ORM? (cont'd)
PerformanceGranular control of when, how, how much data/relationships to load, based on the business logic
Object and query caching
Concurrency & multiple-tenancy
Transactional
Scalable
Extendable (many types of extension points)
ORM FUD
ORMs are slow and generally awful.http://www.slideshare.net/brmeyer/hibernate-orm-performance-31550150
ORMs are over complicated.Back in the EJB/XML days, maybe.
Annotations FTW!
ORM Demo
Why JPA?
JPA
Java Persistence API
JSR 317 (2.0) & JSR 338 (2.1)
Included in both Java SE & Java EE
Provides portability between JPA implementations (with caveats)
Same ORM concepts, but standardized API and query language (JPQL)
JPA Demo
Hibernate ORM
Hibernate ORM
JPA implementation and 100% TCK compliant
Native featuresHQL (Hibernate Query Language): similar to JPQL, but extended
Criteria API
Performance: Fetch strategies, caching, bytecode enhancement, etc.
Extension points
Rich tool set (schema generation/validation, etc.)
Part of JBoss Community
Hibernate Family
Not just ORM
Hibernate Spatial
Hibernate Envers
Hibernate OSGi
Hibernate Search
Hibernate OGM
Hibernate Validator
Hibernate Shards
http://www.slideshare.net/brmeyer/hibernate-orm-features
We've barely scratched the surface!
How to Help:
hibernate.org
/orm/contribute
QUESTIONS?
Q&A
Freenode IRC: brmeyer
@brettemeyer
+brettmeyer