Enterprise systems. Behzad Bordbar Lecture 9

Similar documents
Object Relational Mapping for Database Integration

Aspects of using Hibernate with CaptainCasa Enterprise Client

Easy-Cassandra User Guide

Web Service Caching Using Command Cache

Object-Relational Databases

Using Relational Databases to Provide Object Persistence

CS 111 Classes I 1. Software Organization View to this point:

ORM IN WEB PROGRAMMING. Course project report for 6WW Erik Wang

OpenReports: Users Guide

Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach ) The JdbcTemplate. Class...

PERFORMANCE EVALUATION OF JAVA OBJECT-RELATIONAL MAPPING TOOLS HASEEB YOUSAF. (Under the Direction of John A. Miller)

Operating Systems and Networks

No no-argument constructor. No default constructor found

JIDE Gantt Chart Developer Guide

7 Mutating Object State

Java and RDBMS. Married with issues. Database constraints

Hibernate Reference Documentation. Version: 3.2 cr1

3 Techniques for Database Scalability with Hibernate. Geert Bevin - SpringOne 2009

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

How To Extend Content Broker Storage On Libs Libs (Libs) With Libs 4.5) And Libs 5.5

MA-WA1920: Enterprise iphone and ipad Programming

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

Java Programming Language

Object Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar

Web Development using PHP (WD_PHP) Duration 1.5 months

Core Java+ J2EE+Struts+Hibernate+Spring

Cache Database: Introduction to a New Generation Database

Weaving Stored Procedures into Java at Zalando

Object Oriented Design with UML and Java. PART XVIII: Database Technology

Enterprise JavaBeans 3.1

ArpViewer Manual Version Datum

Object Oriented Database Management System for Decision Support System.

... Introduction... 17

Hibernate Reference Documentation

< Day Day Up > Table of Contents Reviews Examples Reader Reviews Errata Academic Hibernate: A Developer's Notebook By James Elliott

WS-PGRADE Portal Introduction

The Different Types of Search and Execution Systems

Universal E-Catalog pattern

sqlite driver manual

Journal of Chemical and Pharmaceutical Research, 2015, 7(3): Research Article

Introduction to HP ArcSight ESM Web Services APIs

Contents. Apache Log4j. What is logging. Disadvantages 15/01/2013. What are the advantages of logging? Enterprise Systems Log4j and Maven

Specialized Programme on Web Application Development using Open Source Tools

Integrating VoltDB with Hadoop

OTN Developer Day Enterprise Java. Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics

Enterprise Application Development In Java with AJAX and ORM

Dozer v User's Guide

WEB APPLICATION DEVELOPMENT. UNIT I J2EE Platform 9

Object Relational Database Mapping. Alex Boughton Spring 2011

Spring Data JDBC Extensions Reference Documentation

Specialized Programme on Web Application Development using Open Source Tools

OPENRULES. Release TUTORIAL Cloud Application Development

Documentum Developer Program

Tutorial for Spring DAO with JDBC

Java EE Web Development Course Program

JSR-303 Bean Validation

Beginning POJOs. From Novice to Professional. Brian Sam-Bodden

Connecting to WebSphere ESB and WebSphere Process Server

How To Monitor Performance On A Microsoft Powerbook (Powerbook) On A Network (Powerbus) On An Uniden (Powergen) With A Microsatellite) On The Microsonde (Powerstation) On Your Computer (Power

by Charles Souillard CTO and co-founder, BonitaSoft

Stack Allocation. Run-Time Data Structures. Static Structures

Development of Web Applications

Converting Java EE Applications into OSGi Applications

CS2506 Operating Systems II Lab 8, 8 th Tue/03 /2011 Java API

Gentran Integration Suite. Archiving and Purging. Version 4.2

Java SE 8 Programming

Announcements. Comments on project proposals will go out by in next couple of days...

Web development... the server side (of the force)

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

news from Tom Bacon about Monday's lecture

Getting Started with the Internet Communications Engine

Developing WCM based WebSphere Portal application using IBM Rational Application Developer

Building Views and Charts in Requests Introduction to Answers views and charts Creating and editing charts Performing common view tasks

AVRO - SERIALIZATION

WHAT ARE PACKAGES? A package is a collection of related classes. This is similar to the notion that a class is a collection of related methods.

ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. Abstract: twitter.com/adfcodecorner

SSC - Web development Model-View-Controller for Java web application development

Mimer SQL Real-Time Edition White Paper

EMC DOCUMENTUM BUSINESS OBJECT FRAMEWORK

Below is a table called raw_search_log containing details of search queries. user_id INTEGER ID of the user that made the search.

1 File Processing Systems

DIPLOMA IN WEBDEVELOPMENT

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

Building Java Programs

Quiz! Database Indexes. Index. Quiz! Disc and main memory. Quiz! How costly is this operation (naive solution)?

Java Data Objects. JSR000012, Version 0.8 Public Review Draft. Specification Lead: Craig Russell, Sun Microsystems Inc.

Tutorial for Creating Resources in Java - Client

COLLABORATION NAVIGATING CMiC

Rebasoft Auditor Quick Start Guide

Geodatabase Programming with SQL

Copyright 2013 Consona Corporation. All rights reserved

Java Development with Open Source Tools

Portal Factory CMIS Connector Module documentation

Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.

Oracle WebLogic Server

Crystal Reports Migration Guide. Problems and Solutions

jcolibri2 Tutorial Juan A. Recio-García Belén Díaz-Agudo Pedro González-Calero September 16, 2008 Document version 1.2

7. Excursus: Business Information Systems Darmstadt University of Applied Sciences, Department of Computer Science Dr. Markus Voß (Accso GmbH)

F1: A Distributed SQL Database That Scales. Presentation by: Alex Degtiar (adegtiar@cmu.edu) /21/2013

IRF2000 IWL3000 SRC1000 Application Note - Apps with OSGi - Condition Monitoring with WWH push

Transcription:

Enterprise systems Behzad Bordbar Lecture 9 127

Recap Sessions and its API Querying and sample of HQL Pagination Cascading Transactions- concurrency problems Lost Updates Unrepeatable Reads Phantom Read Hibernate uses versioning 128

Long transactions 1) break the long transaction up into two (or more) database transactions 2) use detached objects from the first transaction to carry the necessary information to the presentation layer 3) Reattach the object to do necessary updates (as objects get modified by others) 129

Long transactions Transaction management is a complex subject outside the scope of the course, but: Safe solution: 1. read from the datatabase in the early transactions, 2. allow database writes in the last database transaction of a long transaction, 3. use versioning to check if your writes still make sense. 130

Versioning Persitent object: Add a version instance variable of type int or long to the objects. Don t forget accessor and mutator Type can also be TimeStamp or Calendar Advantage: you can see the time of the version Disadvantage: timing problem (close updates will be treated as identical versions) 131

Versioning Mapping file XX.bhm.xml: Update mapping file: If the version attribute is called version add this after <id> <version name="version" column="version"> Your database will have one extra column for versioning. 132

Versioning Hibernate will take care of the versioning: whenever you make an object dirty in memory, Hibernate will update its version (in memory). Hibernate throws StaleObjectStateException if the version number of the object on disk is not the same as it was when the object was loaded. 133

Versioning Catch the exception and do something about about the conflict For example, report back to the user that the choice he/she has just made is, in fact, no longer available and could they please make another one 134

Mapping-overall view Objects to be persisted Mapping files X.hbm.xml, Y.bhm.xml Runtime objx objy obj Main Hibernate Configuration related hibernate.properties log4j.properties ehcache.xml Database 135

Hibernate objects Entity beans: objects with persistent identity (identifier field managed by Hibernate). Example: User, Customer, Order etc. Value beans: objects which only exist in relationship to an entity bean. Example: Address, CreditCardDetails etc. 136

Hibernate objects For each entity beans sth.java create a mapping file sth.hbm.xml to describe the mapping Put sth.bhm.xml in the same directory as sth.class The connection between any value beans related to sth.java is described in the mapping file of the corresponding entity bean, i.e. sth.hbm.xml 137

Simple Entity Classes without Relationships Consider a class User with three attributes dateofbirth: java.util.date Username: String Gender: String // or enum We add id and version and all setters and getters to create an entity bean 138

Mapping file user.hbm.xml <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "- //Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernatemapping-3.0.dtd"> <hibernate-mapping package="a.b.c"> <class name="user" table="user" lazy="true"> <id name="id" column="id" type="long"> <generator class="sequence"/> </id> <version name="version" column="version"/> 139

Simple Entity Classes without Relationships <property name="dateofbirth" column="dob" type="date"/> <property name="username" not-null="true" unique="true"/> <property name="gender"/> </class> </hibernate-mapping> 140

Mapping Value Objects within Entities Consider the following: What does this mean? What is the black diamond shape? What does the arrow mean? 141

Mapping Value Objects within Entities Technically not different from Person class with an attribute Adddress So we can include in Person.hbm.xml <property name="address" type="string"/> But what if Address has its attribures such as street, postcode? Use components 142

Mapping Value Objects within Entities Instead of a property in Person.hbm.xml include a componets with its own property iems <component name="address" class="address"> <property name="street" column="user_street"/ <property name="postcode" column="user_postcode"/> </component> 143

Mapping Value Objects within Entities 1) child objects are wholly owned by their parents: you cannot have two different parents. 2) A null child property is represented in the database by setting to null all the fields corresponding to the child object. Thus loading such a row will result in a parent object with a null child property, not a parent object with a child object whose properties are all null. 3) Not only can you have multiple components in a class, but one can have multiple components of the same (child) class in a class: such 144 HomeAddress and WorkAddress

Mapping Simple Entity Classes without Relationships What does this mean? Implement the following and save a few Customer and Account objects. You need to create java files and bhm.xml files. For solution see part01.zip 145

Mapping Simple Entity Classes without Relationships Account object might be accessed by various applications, Modify Account.java and Account.hbm.xml Look at both files Solution: part01_version_only_account_files.zip 146

Mapping Value Objects within Entities What does this mean? 147

Exercise Implement this model and test it by saving a Customer object and its two addresses. [No sample code for this one- it is straightforward] 148

Mapping inheritance What does this mean? 149

Mapping inheritance Use a single table Each row of the table can hold an object of any type from the hierarchy. One additional column called discriminator to distinguish between different types in hierarchy You don t need to add a new field called discriminator- it is for Hibernate book keeping 150

Mapping inheritance <class name="address" table="addresses" discriminator-value="only-address"> <id name="id" column="id" type="long"> <generator class="sequence"/> </id> <discriminator column="subclass" type="string"/> <property name="streetname" column="street" type="string"/> <property name="postcode"/> <subclass name="homeaddress" discriminator-value="home-address"> <property name="houseno"/> </subclass> the rest 151

Mapping inheritance Be careful with using not null For a sample see part3.zip 152