Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.

Slides:



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

An Object/Relational Mapping tool Free and open source Simplifies storage of object data in a relational database Removes the need to write and maintain.
Chapter 10: Designing Databases
Spring, Hibernate and Web Services 13 th September 2014.
.NET Database Technologies: Open-Source Frameworks.
Designing a Database Unleashing the Power of Relational Database Design.
1 Lecture 28 Introduction to Databases II - Database Design, SQL and JDBC Overview  Objectives of this Lecture  Logical Database Models  ER Model, Hierarchical.
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
ORM Object-Relational Mapping 1. Object Persistence Persistence is the ability of an object to survive the lifecycle of the process, in which it resides.
Object-Oriented Methods: Database Technology An introduction.
Session-02.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Session-01. Hibernate Framework ? Why we use Hibernate ?
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
Object Persistence and Object-Relational Mapping James Brucker.
Introduction to JPA Java Persistence API Introduction to JPA.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
Data Access Patterns Some of the problems with data access from OO programs: 1.Data source and OO program use different data modelling concepts 2.Decoupling.
NHibernate in Action Web Seminar at UMLChina By Pierre Henri Kuaté 2008/08/27
Object persistence with Hibernate in Decision Deck 1.1 Gilles Dodinet 2 nd Decision Deck Workshop 2008, February.
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
12-CRS-0106 REVISED 8 FEB 2013 CSG2H3 Object Oriented Programming.
.NET Database Technologies: Data Models and Patterns.
File Processing Concepts – Field – combination of 1 or more characters that is the smallest unit of data to be accessed – Record – group of related fields.
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.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.
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.
(1) Introduction to Models using the Play Framework Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University.
Java Data Persistence Using Hibernate Jack Gardner October 2004.
An Introduction to Object/Relational Persistence and Hibernate Yi Li
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Oct * Brad Tutterow. VS 2008.NET 3.5LINQ Entity Framework  The ADO.NET Entity Framework is part of Microsoft’s next generation of.NET technologies.
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.
Persistent State Service 1  Concept  Persistence is the ability of an object state to survive termination of the process in which the object executes.
Hibernate Basics. Basics What is persistence? Persistence in Object Oriented Applications? Paradigm Mismatch.  The Problem of Granularity.  The Problem.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 5th Edition Copyright © 2015 John Wiley & Sons, Inc. All rights.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
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,
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
Faeez, Franz & Syamim.   Database – collection of persistent data  Database Management System (DBMS) – software system that supports creation, population,
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
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
Don't Know Jack About Object-Relational Mapping?
Accessing the Database Server: ODBC, OLE DB, and ADO
Chengyu Sun California State University, Los Angeles
A very brief introduction
POOL persistency framework for LHC
ADO.NET Entity Framework Marcus Tillett
Java Data Persistence Using Hibernate
Hibernate Bayu Priyambadha, S.Kom.
Developing and testing enterprise Java applications
Object Relational Mapping Tools
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Hibernate Java Persistence API

What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence using Relational Databases. Relational Databases are based on the theoretical foundation of the relational data model.

Object Oriented Persistence Object Oriented Languages like Java and C# need to persist Objects, not Tuples. To achieve this programmers would need to write a DAO layer where objects would be persisted in the DB with the help of a DB API such as JDBC or ADO.NET

Problems with OO to Relational Mapping Granularity ◦ Refers to the relative size of types we are working with ◦ Domain models support coarse-grained, fine grained & simple types ◦ SQL supports 2 level, tables and columns Subtypes ◦ Object oriented languages support inheritance and polymorphism ◦ Relational databases do not have this concept.

Problems with OO to Relational Mapping Identity ◦ Object equality is checked by either “==“ or the equals method ◦ Database row identity is expressed with the primary key Associations ◦ Object associations are directional with references ◦ Table associations are non-directional with foreign keys

Object/Relational Mapping(ORM) An ORM aims to solve the Object Relational impedance mismatch. The ORM provides a set of API that enable access to persistent Relational data in an Object Oriented Manner.

JPA 2.0 JPA stands for Java Persistence API The JPA specification details the Interfaces and Annotations that Persistence providers must adhere to. The current discussion revolves around JPA 2.0 (JSR 317)

JPA 2.0 JPA aims to provides transparent persistence, allowing the application to switch between database vendors or even persistence mechanism Provides complete separation of concerns between domain business logic and persistence

Hibernate Hibernate 3.x is an ORM that conforms to JPA 2.0 Hibernate existed well before JPA 2.0 became a specification, as a result there are Hibernate specific classes and annotations as well as JPA specific Where ever possible, JPA classes and annotations are advised since it’s an abstraction over Hibernate allowing the application to change persistence providers.

Entities v/s Objects Entities are POJOs that are annotated thus identifying them as persistable Entities are required to have a field serve as Database Identity. Entities are Granular – they are not primitive wrappers or built in types, neither are they as coarse-grained as having 500 attributes.

Core Hibernate Interfaces

Session An instance of Session represents a single unit-of-work for a given data store. A session wraps a JDBC connection. The instances are light weighted and can be created and destroyed without expensive process. All interactions with the database are through Session objects. The Session acts as the first level cache.

SessionFactory As its name implies it is used to create session objects The SessionFactory is an expensive object to create. It is usually created during application start up. Generally, an application has single SessionFactory and can be shared by all the application threads. The SessionFactory can also provide caching of persistent objects.

Configuration It represents a configuration or properties file for Hibernate. The Configuration object is usually created once during application initialization. The Configuration object reads and establishes the properties Hibernate uses to get connected to a database and configure itself for work. A Configuration object is used to create a SessionFactory and then typically is discarded.

JPA Equivalents HibernateJPA 2.0 SessionFactoryEntityManagerFactory Configured by a Persistence Unit SessionEntityManager Manages a Persistence Context Configuration (org.hibernate.cfg. Configuration) Persistence (javax.persistencePersistence)

Dialects SQL dialects are just like natural language dialects. Databases implement subtle differences in the SQL they use. ◦ Things such as data types for example vary across databases (e.g. Oracle NUMBER and SQL Server uses int ) ◦ Or database specific functionality - selecting the top n rows is different depending on the database. The dialect abstracts this so you don't have to worry about it.

References Java Persistence with Hibernate ◦ Bauer, King (Manning) Pro JPA 2 ◦ Keith, Schincariol(Apress) Hibernate Reference Documentation ◦ nce/en-US/ nce/en-US/ JSR 317 – JPA 2.0 Specification ◦