Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.

Slides:



Advertisements
Similar presentations
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.
Advertisements

NHibernate Object/Relational Persistence for.NET.
.NET Database Technologies: Open-Source Frameworks.
Database Concepts Lec. 5. What Is a Database? Data are unprocessed raw facts that include text, number, images, audio, and video. Information is processed.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Data Management Design
Software Services for Social Network tools implementation Aleksandar Dimov, PhD Sofia University
Chapter 11 Data Management Layer Design
“DOK 322 DBMS” Y.T. Database Design Hacettepe University Department of Information Management DOK 322: Database Management Systems.
Chapter 9: Database Systems
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Chapter 1 Introduction to Databases
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
An Introduction to Hibernate Matt Secoske
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.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Enterprise Object Framework. What is EOF? Enterprise Objects Framework is a set of tools and resources that help you create applications that work with.
Agenda What is Hibernate Spring Integration Questions Overview
Denise Luther Senior IT Consultant Practical Technology Enablement with Enterprise Integrator.
1 DATABASE TECHNOLOGIES BUS Abdou Illia, Fall 2012 (September 5, 2012)
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
What is Architecture  Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project  In the.
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
1 INTRODUCTION TO DATABASE MANAGEMENT SYSTEM L E C T U R E
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
M1G Introduction to Database Development 6. Building Applications.
CODD’s 12 RULES OF RELATIONAL DATABASE
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
.NET Database Technologies: Data Models and Patterns.
PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 4th Edition Copyright © 2009 John Wiley & Sons, Inc. All rights.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Object Persistence Design Chapter 13. Key Definitions Object persistence involves the selection of a storage format and optimization for performance.
JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.
1 Architectural Overview For application developers, assembling enterprise beans requires little or no expertise in the complex system-level issues that.
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.
Spring 2009Computer Science Department, TUC-N Object Oriented Methods Architectural Patterns 3.
1 Mapping to Relational Databases Presented by Ramona Su.
Domain and Persistence Patterns. Fundamental Pattern Types Design Patterns Business Logic Patterns.
Databases Shortfalls of file management systems Structure of a database Database administration Database Management system Hierarchical Databases Network.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Java Data Persistence Using Hibernate Jack Gardner October 2004.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Chapter 9 Database Systems © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 9 Database Systems. © 2005 Pearson Addison-Wesley. All rights reserved 9-2 Chapter 9: Database Systems 9.1 Database Fundamentals 9.2 The Relational.
Object Oriented Database By Ashish Kaul References from Professor Lee’s presentations and the Web.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
OOPSLA 2001 Choosing Transaction Models for Enterprise Applications Jim Tyhurst, Ph.D. Tyhurst Technology Group LLC.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
March R McFadyen1 Object Relational Mapping example TopLink Part of Oracle environment Provides an Object/Relational Mapping Layer References:
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
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
Sean Chambers.  ORM stands for Object Relational Mapper  Maps your POCO (plain old clr objects) to your relational model using XML config  Relieves.
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.
uses of DB systems DB environment DB structure Codd’s rules current common RDBMs implementations.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
DBMS & TPS Barbara Russell MBA 624.
Developing a Model-View-Controller Component for Joomla Part 3
Unit I-2.
Transactions and Concurrency
Developing and testing enterprise Java applications
Presentation transcript:

Hibernate Persistence

What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage. Relational database  SQL  Using SQL in Java  Persistence object-oriented applications: ORM

What is Hibernate? Popular Open Source (LGPL) Object/Relational Mapping (ORM) tool Transparent persistence for POJOs (Plain Old Java Objects) Core of JBoss CMP 2.0 impl.

Why Hibernate? Minimizes Code Does not require a container Model is not tied to persistence implementation, Retains natural object model (transparent)

Object/Relational Mapping JavaObject int id; String name; String getName() int getId() void setName(String) void setId(int) SQL Table id [int] primary key, name [varchar(50)] Magic Happens Here (O/R Mapper – i.e. Hibernate)

Course Object Model

Persistence Tasks Class mapping  Class to Table mapping  Object ID to Primary Key Attribute Mapping  Primary Attribute to Column  User defined data type to embedded type Inheritance Mapping Relationship Mapping  One to Many  Many to One

Persistence /Concurrency Pattern Introduced Martin Fowler 《企业应用架构模式》

Persistence What is Persistence Why Persistence is Importance History of persistence  Plan text  RDB(OODB?)  XML

Mapping to a Relational Database Metadata Mapping Identity Field Lazy Load Query Object

Metadata Mapping Hold details of object-relational mapping in metadata. Hibernate as sample

Identity Field Save a database id field in an object to maintain identity between an in-memory object and a database row.

Identity Field Choosing your Key  meaningful key  meaningless key  simple key  compound key  table-unique key  database-unique key

How to get a new Key Database counter  it's non-standard and not available in all databases. Key table  Separate transaction is needed GUID  Large keys may also lead to performance problems, particularly with indexes

Identity Map Ensure each object only gets loaded once by keeping every loaded object in a map. Lookup objects using the map when referring to them A Identity Map keeps a record of all the objects that have been read from the database in a single business transaction. Whenever you want an object, you check the Identity Map first to see if you already have it.

Lazy Load An object that doesn't contain all of the data you need, but knows how to get it.

Query Object An object that represents a database query SQL can be an involved language, and many developers are not particularly familiar with it..

Query Object( cont. )

Concurrency When Concurrency problem raised? Why Concurrency is difficult to deal with  It is difficult to enumerate the possible scenarios that can get you into trouble  it is hard to test for

Execution Contexts Connection Session  A session is a long running interaction between a client and server Transaction Process Thread

Transactions The primary tool for handling concurrency in enterprise applications is the transaction. ATM machine example

Transaction Resources Most enterprise applications run into transactions in terms of databases. But there are plenty of other things than can be controlled using transactions, such as  message queues,  printers, As a result technical discussions of transactions use the term 'transactional resource' to mean anything that is transactional: that is uses transactions to control concurrency.

Transaction types long transaction.  making a transaction span multiple requests is generally known as a long transaction.  Not recommended request transaction  start a transaction at the beginning of a request and complete it at the end. late transaction  open a transaction as late as possible,

Business and System Transactions System transactions  transactions supported by RDBMS systems and transaction monitors Business transaction  Transaction that logically defined by a business requirement

Concurrency Patterns Unit of work Optimistic Offline Lock Pessimistic Offline Lock

Unit of Work Maintains a list of objects that are affected by a business transaction and coordinates the writing out of changes and resolution of concurrency problems.

How it Works Unit of Work is an object that keeps track of these changed things, such as inserted, updated or deleted.

Unit of Work

Optimistic Offline Lock Prevent conflicts between concurrent business transactions, by detecting a conflict and rolling back the transaction.

Optimistic Offline Lock

How it Works

Pessimistic Offline Lock Prevent conflicts between concurrent business transactions by allowing only one business transaction to access data at once

Pessimistic Offline Lock

How it Works have an exclusive write lock. That is, require only that a business transaction acquire a lock in order to edit session data. This avoids conflict by not allowing two business transactions to simultaneously make changes to the same record.