Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.

Slides:



Advertisements
Similar presentations
V 6, Mats Strandberg ORM With Hibernate.
Advertisements

Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Persistence Jim Briggs 1. 2 Database connectivity: JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets)
Spring, Hibernate and Web Services 13 th September 2014.
.NET Database Technologies: Open-Source Frameworks.
Hibernate 1. Introduction ORM goal: Take advantage of the things SQL databases do well, without leaving the Java language of objects and classes. ORM.
Pragmatic Application Building: Step by Step Jay Sissom Principal Systems Analyst Indiana University
Session-02.
Session-01. Hibernate Framework ? Why we use Hibernate ?
Using Third-Party Frameworks in Building Blocks™ David Ashman Principal Architect, Product Development.
An Introduction to Hibernate Matt Secoske
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Data Persistence and Intro to Hibernate.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Object Persistence and Object-Relational Mapping James Brucker.
CIS 764 Kansas State University
Introduction to JPA Java Persistence API Introduction to JPA.
Rice KRAD Data Layer JPA Design Eric Westfall July 2013.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Towards Bboogle 3.0.0: a Technical Walkthrough Patricia Goldweic Sr. Software Engineer AR&T, Northwestern University Brian Nielsen Manager, Faculty Support.
2007 JavaOne SM Conference | Session BOF-4181 | BOF-4181 Migrating a Spring/Hibernate Application to Java Platform, Enterprise Edition (Java EE) 5 Adrian.
NetArchive Suite Workshop 2011 Technical Track - Code refactoring with the Spring Framework.
UPortal Developers MIT August 2004 Persistence Strategy for uPortal 3 Mike DeSimone the r-smart group
Agenda What is Hibernate Spring Integration Questions Overview
Database refactoring. For the beginning… Avoid overspecialization Application developerDatabase developer Developer Communication Cooperation Exchange.
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
Compiling Mappings to Bridge Applications and Databases Melnik, Adya and Research.
Object persistence with Hibernate in Decision Deck 1.1 Gilles Dodinet 2 nd Decision Deck Workshop 2008, February.
CDM Developer Workshop. TDWG Andreas Kohlbecker Taxonomic Workflow in the EDIT Platform for Cybertaxonomy Purpose What do you want from this workshop?
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
Seminar on. Overview Hibernate. What is it? Hibernate. How does it work? Hibernate Tools.
Dali JPA Tools. About Dali Dali JPA Tools is an Eclipse Web Tools Platform sub-Project Dali 1.0 is a part of WTP 2.0 Europa coordinated release Goal -
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 14 Using Relational Databases to Provide Object Persistence (Overview) Modern Database.
Spring Database Access Ojitha Kumanayaka Copyright © Virtusa, 2007.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
Topic : Hibernate 2: Object Persistence and ORM Kaster Nurmukan.
Ganymede Simultaneous Release | © 2008 by Springsite B.V., The Netherlands made available under the EPL v1.0 Teneo Ganymede Simultaneous Release.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
JAVA EE 6 Best Practices for Migrating Spring to WTF ?!?
Persistence – Iteration 4 Vancouver Bootcamp Aaron Zeckoski
ESG-CET Meeting, Boulder, CO, April 2008 Gateway Implementation 4/30/2008.
By Srinivas Mahakud Java Persistence API JPA. Review Topics: Introduction what is the JPA? What is the JPA contains of? Why developers should Create the.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Simplifying the Code First Approach in the Entity Framework Dhananjay Kumar Infragistics Consultant Microsoft MVP
Introduction – ORM, Helloworld Application
Fundamentals of MyBATIS
IS-907 Java EE Introduction to JPA. Java Persistence API A framework for using relational databases in Java programs mapping between tables and classes,
JPA in Vaadin CSCI 3130 Winter What is JPA?  Java Persistence API  Allows for “easy” storage of Java Objects  Is a type of Object Relational.
JPA Java Persistence API JAVA Enterprise Edition
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
JAVA Persistence API(JPA) What is it? How would we use it in a project? Should we use it? -Parag Chaudhari.
Hibernate Online Training. Introduction to Hibernate Hibernate is a high-performance Object-Relational persistence and query service which takes care.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
Fall CIS 764 Database Systems Engineering L11: Object Relational Mapping … (a) ORM, Object persistence (b) Pets sequence.
HIBERNATE/Java Overview of technology for Hibernate by محمد حسن کاظمی پوران Master : M.M.Nematollahi.
New Technology: Why, What ,How
Chengyu Sun California State University, Los Angeles
A very brief introduction
Entity Framework By: Casey Griffin.
…and web frameworks in general
Testing a persistence layer
…and web frameworks in general
Developing and testing enterprise Java applications
Teneo Ganymede Mini Deck
CS4961 Software Design Laboratory Understand Aquila Backend
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com

About Me Senior Developer at DrillingInfo since September Been in the industry for almost ten years Been doing Java development for the past five years

About DrillingInfo Subscription based website which aggregates and organizes state regulatory data and other data in an easy-to-use format. We employ many different loaders which download data from state agencies and from other sources. We have a huge database (10 GBs of data at last count?) of information which we are always updating and querying. Always looking for ways of improving performance, which lead us to Hibernate.

Overview In this talk, I will talk about our experiences migrating an application from plain old SQL on JDBC to Hibernate on JPA. Topics covered: – Introduction to the technologies used – Refactoring and design patterns (DAO) – Generating entity classes from the schema – Converting SQL queries to JPQL – Introduction to Guice framework – Impact of Migrating to JPA/Hibernate

What is Hibernate? Hibernate is an ORM (Object Relational Mapping) tool. Maps the Relational Model in the database to the Object Model in Java. Tables are mapped to classes. Columns are mapped to JavaBean properties. Replaces SQL with HQL, a database- independent query language that navigates object relations rather than table relations.

What is JPA? JPA is the Java Persistence API, the entity persistence model for EJB 3.0 Standardized persistence framework which is implemented by Hibernate (or TopLink, Cayenne, etc.) JPA Annotations and persistence.xml provide vendor independent configuration EntityManager provides vendor independent access to persistence Replaces vendor specific query languages (HQL) with standard (JPQL)

Why JPA? JPA is the standard, and standards are good! Using JPA does not tie you to Hibernate. JPA gives you most of the features of plain old Hibernate, except: – No criteria queries in JPA 2.0  Criteria query is a neat feature of Hibernate that constructs query using Java-based combinators instead of alternate query language, getting the benefit of IntelliSense and Eclipse’s refactoring tools. – JPA doesn’t have Hibernate’s DeleteOrphan cascade type Delete Orphan is a useful annotation that directs Hibernate to deletes entities in a collection if the parent is deleted, preventing orphaning. – JPA doesn’t have an equivalent to Hibernate’s ScrollableResults But, all of these features are accessible to an otherwise fully JPA application!

What is Guice? Guice is a very lightweight dependency injection framework. Simpler to set up than a full blown IoC container like Spring. Guice is focused on IoC, Spring has become an ecosystem. Good or bad, you decide! Guice is XML free, configured in regular Java code and annotations. Though Spring 3 is advertised to do this as well.

On to the Code! Now that we’ve laid the groundwork, let’s see this in action! I’ve create a very simple Wicket application which demonstrates the principles introduced so far and a migration strategy: – Step 1: A basic JDBC and SQL driven web-app – Step 2: Migrating to Guice-driven DAOs – Step 3: Migrating from JDBC to JPA JPA

What was the Point? Substantially reduces the amount of data access code, partly generated but largely managed by Hibernate. In our case, this is a savings of thousands of lines of code. Better performance. Dirty checks and versioning by Hibernate reduces the amount of data that has to be persisted, code that we were writing ourselves. IOHO, it’s just a better programming model!