Sean Chambers.  ORM stands for Object Relational Mapper  Maps your POCO (plain old clr objects) to your relational model using XML config  Relieves.

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.
Object Relational Mapping (ORM). Persistence Almost all applications require some form of persistence. Almost all persistence is done using relational.
TPTP Data Model 1 Database support for TPTP EMF based data models using Elver/Hibernate Guru Nagarajan July 14, 2006.
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Raptor Technical Details. Outline Workshop structured by Raptor workflow – Raptor Event model. – ICA log file parsing – ICA/MUA event storage – ICA event.
NHibernate Object/Relational Persistence for.NET.
Object Relational Mapping – ORM Entity Framework
.NET Database Technologies: Open-Source Frameworks.
DEVELOPING APPLICATIONS WITH LINQ 2 SQL Sidar Ok
Hibernate 1. Introduction ORM goal: Take advantage of the things SQL databases do well, without leaving the Java language of objects and classes. ORM.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
Object Relational Mapping. What does ORM do? Maps Object Model to Relational Model. Resolve impedance mismatch. Resolve mapping of scalar and non-scalar.
ORM Technologies and Entity Framework (EF)
Session-02.
Session-01. Hibernate Framework ? Why we use Hibernate ?
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Object Persistence and Object-Relational Mapping James Brucker.
Maven for building Java applications By Nalin De Zoysa
PHP Data Object (PDO) Khaled Al-Sham’aa. What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface.
JDBC and Hibernate Joshua Scotton. Connecting to Relational DBs.
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
CHAPTER 14 USING RELATIONAL DATABASES TO PROVIDE OBJECT PERSISTENCE (ONLINE) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database.
Object/Relational Mapping with Hibernate Practical ORM.
Relational Databases Database Driven Applications Retrieving Data Changing Data Analysing Data What is a DBMS An application that holds the data manages.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Reactive Database Access in Scala with Slick 3
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Intoduction to NHibernate. Agenda Overview of NHibernate Models and Mappings Configuration Sessions and Transactions Queries.
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.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Java Data Persistence Using Hibernate Jack Gardner October 2004.
Object-Relational Mapping with Hibernate Brian Sam-Bodden Principal Partner Integrallis Software, LLC. August 1 - 5, 2005.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
Intoduction to NHibernate. Agenda Overview of NHibernate Models and Mappings Configuration Sessions and Transactions Queries.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
Intoduction to NHibernate. Agenda Overview of NHibernate Models and Mappings Configuration Sessions and Transactions Queries.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
PHP Workshop ‹#› PHP Data Object (PDO). PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Hibernate Basics. Basics What is persistence? Persistence in Object Oriented Applications? Paradigm Mismatch.  The Problem of Granularity.  The Problem.
Persistence – Iteration 4 Vancouver Bootcamp Aaron Zeckoski
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
Fundamentals of MyBATIS
Interacting with LexEVS 5.0 LexEVS in a Distributed Environment November 2009.
 Who I am  What is NHibernate? ◦ Object Relational Mapper ◦ A framework for building advanced frameworks ◦ Ported from Java ◦ A wide NHibernate ecosystem.
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 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.
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.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Reactor An ORM framework for ColdFusion Presentation By: Doug Hughes
Fall CIS 764 Database Systems Engineering L11: Object Relational Mapping … (a) ORM, Object persistence (b) Pets sequence.
Introduction to Entity framework
DEPTT. OF COMP. SC & APPLICATIONS
Chengyu Sun California State University, Los Angeles
Entity Framework By: Casey Griffin.
Java Data Persistence Using Hibernate
An Introduction to Entity Framework
.NET Database Technologies:
Java Database Connectivity
Chengyu Sun California State University, Los Angeles
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Sean Chambers

 ORM stands for Object Relational Mapper  Maps your POCO (plain old clr objects) to your relational model using XML config  Relieves developer from 95% of common CRUD code

 MSSQL 2000, 2005 etc..  SqlCe, Sqlite, Firebird embedded db’s  MySQL  PostgreSql  Oracle  SyBase  Db2  Many many more

Database NHibernate SessionSessionFactory Persistence Layer Domain Model

Configuration SessionFactorySession 1.SessionFactory consumes the configuration 2.Shared among all application threads 3.Instantiation is expensive as parsing of mapping files is performed 4.Validates mapping files, showing errors if incorrect mapping 5.SessionFactory provides Session objects that are used to interact with the database 6.A Session object holds an open connection to the database for loading objects, and transaction management

 1. Web.config/app.config  2. Mapping files  Configuration defines db dialect, db connection and mapping files assembly  Sample mapping file:

 Manages interaction with database, contains all basic CRUD operations ◦ session.Get(typeof(Order), orderId); ◦ Session.Load(typeof(Order), orderId); will throw exception ◦ session.Save(myOrder); ◦ session.SaveOrUpate(myOrder); ◦ Session.Delete(myOrder);

 Query/HQL API  Criteria API  Native SQL

 Nhibernate contains an extremely powerful querying API  IQuery ◦ Provides a method for building a DB query through HQL (hibernate query language) IQuery q = session.CreateQuery(“from Orders where Total>:total”).SetDecimal(“Total”, 30m).OrderBy(Order.Asc(“Title”)).SetFirstResult(20).SetMaxResults(10); IList orders = q.List (); IQuery q = session.CreateQuery(“from Orders where Total>:total”).SetDecimal(“Total”, 30m).OrderBy(Order.Asc(“Title”)).SetFirstResult(20).SetMaxResults(10); IList orders = q.List ();

 Constructs a query using an API  Is more extensible than HQL ICritiera crit = session.CreateCriteria(typeof(Order)).Add(Expression.Gt(“Total”, 30m)).SetFirstResults(20); IList orders = crit.List (); ICritiera crit = session.CreateCriteria(typeof(Order)).Add(Expression.Gt(“Total”, 30m)).SetFirstResults(20); IList orders = crit.List ();

 Allows you to execute native SQL queries  Good for legacy adoption IList orders = session.CreateSqlQuery(“select {order.*} from Order {order} where {order.Total} ();

 NHibernate will track changes performed to an object a.k.a. “Dirty” objects  Will implicitly call Save: Order order = session.Load(typeof(Order), orderId); order.Total = 69.95m; session.Flush(); Order order = session.Load(typeof(Order), orderId); order.Total = 69.95m; session.Flush(); Flush() is also called when transaction is committed

 Collection Mapping  Component Mapping  Inheritance Mapping

 One of the more complex aspects of NHibernate  Different collection types: ◦ bag : collection of values that are not distinct ◦ list : collection of values that have an index ◦ set : distinct set of values ◦ map :hash/dictionary. Keys and value  Bag and List map to IList, bag with caveats (add method)  Set maps to Iesi.Collections.Generics.HashedSet  Map maps to IDictionary

 Maps an objects associations into a single table  Good for value objects that do not require an identity (DDD)  Customer.Address with Street and City fields would map to:  Table: Street, Columns AddressStreet, AddressCity etc…

 Three different strategies for mapping inheritance hierarchies  Table per class hierarchy (1 table total) ◦ Uses a discriminator to identify the type of the row ◦ Will have null values for certain columns  Table per subclass (1+n tables) ◦ One for the base class, one table for each subclass  Table per concrete class (n tables) ◦ No table for the base class

 Fluent NHibernate ◦  This tool was just recently forked from Jeremy Miller’s StructureMap

 Absolutely necessary with any ORM  Inserts proxies at traversal points  Once navigation to assoc./collection is performed, NHibernate will retrieve data on-the-fly and replace the proxy object  Can modify behavior to “Eager” load related objects  Can be problematic in certain scenarios, namely JSON serialization  Saves you from loading an entire object graph when all you need is a subset of data

 Legacy applications ◦ Often, it is difficult to make your model map to your established db structure, not impossible however  ETL/Data Mining scenarios  Small Domain Models/No Domain Model

 Good post on performance benchmarks: nceUrbanLegend.aspx nceUrbanLegend.aspx  Performance benchmark results Test nth Run 1 st RunNth Run Inline SQL1312.5ms~430ms Parameterized Query ms~350ms SPROC1390.6ms~320ms NHibernate1565.3ms~560ms NHibernate w/Transaction ms~300ms