OpenAccess ORM Advanced Topics Kevin Babcock April 9, 2009.

Slides:



Advertisements
Similar presentations
Advanced SQL (part 1) CS263 Lecture 7.
Advertisements

Transactions - Concurrent access & System failures - Properties of Transactions - Isolation Levels 4/13/2015Databases21.
Chapter 13 (Web): Distributed Databases
ACS R McFadyen 1 Transaction A transaction is an atomic unit of work that is either completed in its entirety or not done at all. For recovery purposes,
Chapter 3 An Introduction to Relational Databases.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
1 A Closer Look Chapter 2. 2 Underlying Concepts of Databases and Transaction Processing.
1 The Big Picture of Databases We are particularly interested in relational databases Data is stored in tables.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
Managing Concurrency in Web Applications. DBI 2007 HUJI-CS 2 Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses.
Transaction Management and Concurrency Control
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 1) Academic Year 2014 Spring.
LINQ Boot Camp ADO.Net Entity Framework Presenter : Date : Mahesh Moily Nov 26, 2009.
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
Database Management System Module 5 DeSiaMorewww.desiamore.com/ifm1.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Stored Procedures, Transactions, and Error-Handling
1cs Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses by multiple users Concurrent accesses intersect.
Transaction Processing Concepts. 1. Introduction To transaction Processing 1.1 Single User VS Multi User Systems One criteria to classify Database is.
Overview – Chapter 11 SQL 710 Overview of Replication
DATABASE TRANSACTION. Transaction It is a logical unit of work that must succeed or fail in its entirety. A transaction is an atomic operation which may.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Objectives After completing this lesson, you should be able to do the following: Describe each data manipulation language (DML) statement Insert rows.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
DAT602 Database Application Development Lecture 2 Review of Relational Database.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Database Systems Recovery & Concurrency Lecture # 20 1 st April, 2011.
Object Oriented Programming
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Advanced Database- Dr. Arasteh1 Advanced Database Bahman Arasteh ( Ph.D, Software Engineering ) Department of Software Engineering, Azad University of.
CM Name : p.rajesh Year/Semester : VI Semester Subject : Advanced database system Subject Code : CM-603 Topic : Advanced database concepts Duration.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 Transations.
Software System Lab. Transactions Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
1 Advanced Database Concepts Transaction Management and Concurrency Control.
Data The fact and figures that can be recorded in system and that have some special meaning assigned to it. Eg- Data of a customer like name, telephone.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Hibernate Thuy, Le Huu. Pentalog VN. Agenda Hibernate Annotations Improving performance – Lazy loading – Fetching Strategies – Dynamic insert, dynamic.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
SQL Basics Review Reviewing what we’ve learned so far…….
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Chapter 2 The Big Picture. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 2-2 Databases We are particularly interested in relational databases.
CHAPTER 7 LESSON B Creating Database Reports. Lesson B Objectives  Describe the components of a report  Modify report components  Modify the format.
Working with Data Blocks and Frames
DCL – Data Control Language
Databases We are particularly interested in relational databases
Entity Framework: Relations
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Transactions Properties.
On transactions, and Atomic Operations
The PROCESS of Queries John Deardurff
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
On transactions, and Atomic Operations
The PROCESS of Queries John Deardurff
Interrogating the Transaction Log
Batches, Transactions, & Errors
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Objectives In this lesson, you will learn about:
Module 10: Creating Transactional Business Processes
Advanced Topics: Indexes & Transactions
Database management systems
Presentation transcript:

OpenAccess ORM Advanced Topics Kevin Babcock April 9, 2009

Agenda OpenAccess ORM Overview Inheritance & Polymorphism Transactions Fetch Plans & Fetch Groups Wrap Up

OpenAccess ORM Overview Object/Relational Mapper Bridge the gap  database | application code Forward Mapping Map classes to tables Reverse Mapping Map tables to classes LINQ Perform LINQ queries with OpenAccess

Inheritance & Polymorphism Extend the functionality of existing classes with inherited classes Bird parrot = new Bird(); parrot.Name = “Polly”; parrot.WingSpan = “12”; parrot.Speak(); parrot.Walk(); parrot.Fly();

Inheritance & Polymorphism Inheritance - 4 supported “scenarios” Flat Mapping Vertical Mapping Mixed (Flat & Vertical) Mapping Horizontal Mapping *The default mapping strategy is Flat Mapping

Inheritance & Polymorphism Inheritance – Flat Mapping [default setting] All properties from subclasses are mapped to a single table Requires a discriminator column to identify each row Advantages: No extra joins required Only one INSERT/UPDATE/DELETE required Disadvantages: Extra columns that aren’t always used An extra “discriminator” column

Inheritance & Polymorphism Inheritance – Flat Mapping [default setting] Discriminator Column Named voa_class Type is INTEGER, unless another class in the hierarchy has a ClassID other than INTEGER If each class in the hierarchy has at most one subclass, the discriminator column can be disabled Set the ClassID to {no}

Inheritance & Polymorphism Inheritance – Vertical Mapping Each class has its own table containing only its fields Advantages: Normalization Subclasses can be added easily No discriminator column required Disadvantages: Multiple joins must be used Multiple INSERT/UPDATE/DELETE statements required for database changes

Inheritance & Polymorphism Inheritance – Mixed (Flat & Vertical) Mapping The mapping strategy is set on a per-class basis, so any combination can be used to map inherited classes. Strategies can be “tweaked” in order to maximize performance and database space usage

Inheritance & Polymorphism Inheritance – Horizontal Mapping Can only be enabled for the topmost class in a hierarchy The superclass is not represented in the database, and should be marked as abstract. Advantages: As fast as Flat Mapping No joins required Common attributes defined in superclass Disadvantages: Each derived class starts a new hierarchy De-normalized database Querying the topmost class is expensive

Inheritance & Polymorphism Polymorphism aka “late-binding” Allows values of different data types to be handled using a uniform interface Animal animal = new Dog(); animal.Speak(); // returns "Bark" animal = new Bird(); animal.Speak(); // return “Chirp"

DEMO

Transactions Transactions control the concurrent access of data by multiple programs. OpenAccess ORM maintains transactional consistency in the database by adhering to the ACID principles: Atomicity, Consistency, Isolation, Durability

Transactions Atomicity: changes to the values in persistent states are either executed in their entirety or not at all. If one part of the transaction fails, the entire transaction fails Consistency: the state of the database must remain consistent before and after a transaction If the transaction fails, the rollback must reestablish the consistent state of the database

Transactions Isolation: changes to values in persistent instances are isolated from changes to the same instance in other transactions Transactions should appear to be running independently from other transactions Durability: transactions committed to the database will not be lost This is guaranteed by the database backend

Transactions When using OpenAccess ORM, the following operations require a transaction: Reading persistent objects from the database Inserting new persistent objects into the database Modifying existing objects in the database Deletion of objects from the database

Transactions Operations for a transaction are accessible through the ITransaction interface Obtained from IObjectScope.Transaction IObjectScope scope = ObjectScopeProvider.GetNewObjectScope(); scope.Transaction.Begin(); Customer customer = new Customer(); customer.Name = “John Doe”; scope.Add(customer); scope.Transaction.Commit();

Transactions If you decide that you no longer wish to persist the changes to the database, you can rollback the transaction. scope.Transaction.Begin(); Customer customer = new Customer(); customer.Name = “John Doe”; scope.Add(customer); // perform some logic here scope.Transaction.Rollback();

Transactions RetainValues [true] – controls whether objects retain IObjectScope.TransactionProperties RetainValues [true] – controls whether objects retain their values after commit of the transaction RestoreValues [false] – controls whether the values of persistent objects are restored to their originals when a transaction is rolled back AutomaticBegin [false] – automatically restarts a new transaction after every commit and rollback FailFast [true] – determines whether a transaction commit or flush should fail at the first failure

DEMO

Fetch Plans & Fetch Groups Allow you to specify which fields are retrieved from the database Results in more optimized database queries FetchGroups Used to mark fields for each class Used to indicate field recursion-depth Can be used with one or more classes FetchGroup names have a global scope

Fetch Plans & Fetch Groups Consists of one or more FetchGroups FetchGroups are combined additively Default FetchGroup Created for each class Retrieves fields of basic type or single-reference type only the ID of the referenced object will be retrieved

Fetch Plans & Fetch Groups Defining FetchGroups In code [default]: [Persistent]  public class Employee  {     [FetchField("FG_empName")]     private string firstname;     [FetchField("FG_empName")]     private string lastname;  } In the config file:  <class name="Employee">      <fetch-group name="FG_empName">          <field name="firstname"/>          <field name="lastname"/>      </fetch-group>  </class>

DEMO

Wrap Up OpenAccess ORM Overview Inheritance & Polymorphism Transactions Fetch Plans & Fetch Groups

blogs.telerik.com\kevinbabcock Questions ??? blogs.telerik.com\kevinbabcock tv.telerik.com