Java Persistence API part 2 INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J

Slides:



Advertisements
Similar presentations
Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Advertisements

Persistence Jim Briggs 1. 2 Database connectivity: JDBC Java Database Connectivity An API for connecting Java programs (applications, applets and servlets)
Course Introduction INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Spring, Hibernate and Web Services 13 th September 2014.
Container Managed Persistence. General Guidelines Home and Remote interfaces are implemented the same as for bean managed persistence Entity Bean class.
The Observer Design Pattern By Bradley Woods. Pattern Overview Consists mainly of subjects and observers. – Subjects update all observers on state changes.
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
CIS 764 Kansas State University
Introduction to JPA Java Persistence API Introduction to JPA.
Hibernatification! Roadmap for Migrating from Plain Old SQL on JDBC to JPA on Hibernate Duke Banerjee Senior Developer, DrillingInfo.com.
JPQL Java Persistence Query Language. Introduction The Java Persistence API specifies a query language that allows to define queries over entities and.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Think Possibility Integrating Web Applications With Databases.
Maven for building Java applications By Nalin De Zoysa
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
EJB Entity Beans “Modeling your data”.
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
Entity Beans BMP Celsina Bignoli
© D. Wong  Indexes  JDBC  JDBC in J2EE (Java 2 Enterprise Edition)
95-843: Service Oriented Architecture 1 Master of Information System Management Service Oriented Architecture Lecture 10: Service Component Architecture.
Session Beans INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Java Persistence API part.2 Eriq Muhammad Adams J |
Message Driven Beans & Web Services INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Creating and using Persistent Data From before – Where does the data come from? – Why is it kept? – How is it used? Affects design and implementation choices.
Hitachi Consulting IOUG Collaborate ‘08 EJB 3.0 Java Persistence API (JPA) with Oracle TopLink Bill Lyons Systems Architect Hitachi Consulting
EJB 3.0 Persistence Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Java Database Connectivity (JDBC). Topics 1. The Vendor Variation Problem 2. SQL and Versions of JDBC 3. Creating an ODBC Data Source 4. Simple Database.
Programming in R SQL in R. Running SQL in R In this session I will show you how to: Run basic SQL commands within R.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
Eriq Muhammad Adams J. Informatics Engineering University of Brawijaya.
JPA Java Persistence API. Introduction The Java Persistence API provides an object/relational mapping facility for managing relational data in Java applications.
Eriq Muhammad Adams J. Informatics Engineering University of Brawijaya.
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
UNIT III - JDBC JDBC Overview – JDBC implementation – Connection class – Statements - Catching Database Results, handling database Queries. Networking–
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
The Java Persistence API ©SoftMoore ConsultingSlide 1.
Java Persistence API part 1 INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
By Srinivas Mahakud Java Persistence API JPA. Review Topics: Introduction what is the JPA? What is the JPA contains of? Why developers should Create the.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
Introduction to ORM Hibernate Hibernate vs JDBC. May 12, 2011 INTRODUCTION TO ORM ORM is a programming technique for converting data between relational.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
JAVA Persistence API(JPA) What is it? How would we use it in a project? Should we use it? -Parag Chaudhari.
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.
CS520 Web Programming Full Text Search
Database: JDBC Overview
Don't Know Jack About Object-Relational Mapping?
Chengyu Sun California State University, Los Angeles
Abstract Factory & Command Pattern
Reflection API, JDBC, Hibernate, RMI
Database JDBC Overview CS Programming Languages for Web Applications
Advanced Java Programming
Java Database Connectivity
Entity Beans B.Ramamurthy 2/17/2019 BR.
Developing and testing enterprise Java applications
Social Practice of the language: Describe and share
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Java Persistence API part 2 INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J

Agenda  JPQL (Java Persistence Query Language)  EAO Pattern  Session Façade Pattern

JPQL (Java Persistence Query Language)  Dynamic Query with JPQL  entityManager.createQuery(”select object o from Inventory o”).getResultList();  Binding parameter :  entityManager.createQuery(”select object o from Inventory o where o.year =:year”).setParameter( ”year”, year ).getResultList();  entityManager.createQuery(”select object o from Inventory o where o.year =?1”).setParameter(0, year).getResultList();

JPQL (Java Persistence Query Language) (cont.)  @NamedQuery(name="findAllInventory", queryString="select object(o) from Inventory queryString="select object(o) from Inventory o where queryString="select object(o) from Inventory o where o.region=?1 ")}) public class Inventory implements Serializable{ ………

JPQL (Java Persistence Query Language) (cont.)  entityManager.createNamedQuery(”findAllI nventory”).getResultList();  entityManager.createNamedQuery(”findInve ntoryByYear”).setParameter(” year”, year).getResultList();  entityManager.createNamedQuery(”findInve ntoryByRegion”).setParameter(0, region).getResultList();

JPQL (Java Persistence Query Language) (cont.)  Bulk Update and Delete Operation public int bulkDeleteEmptyInventory() { return em.createQuery("delete from Inventory o where o.quantity = 0").executeUpdate(); }

JPQL (Java Persistence Query Language) (cont.)  Native SQL Query  entityManager.createNativeQuery(”select * from inventory”, entity.Inventory.class).getResultList();  entityManager.createNativeQuery(”select * from inventory where year=?”, entity.Inventory.class ).setParameter(0, year).getResultList();  Resultset Mapping = “InventoryResults", entities = Entity.Inventory.class));  entityManager.createNativeQuery(”select * from inventory”, InventoryResults).getResultList();

JPQL (Java Persistence Query Language) (cont.)  Native Named SQL name = "findInventoryByYear", query = "SELECT * FROM inventory WHERE year = ?)", resultClass = name = "findInventoryByYear", query = "SELECT * FROM inventory WHERE year = ?)", resultSetMapping = "InventoryResults")  entityManager.createNamedQuery(”findInventoryByYea r”).setParamater(0,year).getResultList();

EAO Pattern  Stand for Entity Access Object Pattern  Separate or decouple data access with any business logic code.  It’s useful and widely used pattern because its reduce maintenance problem.

EAO Pattern (cont.)  Illustration Sample Fig. taken from EJB 3 in Action, Manning

Session Façade Pattern  The primary reasons the Session Façade pattern was invented was to reduce the number of remote calls for previous EJB incarnations, and this still holds true for EJB 3.

Session Façade Pattern (cont.)  Illustration sample Fig. taken from EJB 3 in Action, Manning

Demo  JPQL Demo in JPQLDemo.zipJPQLDemo.zip  EAO Pattern and Session Façade Pattern Demo in EAOSessionFacade.zipEAOSessionFacade.zip

References  EJB 3 in Action, Manning  Beginning EJB 3 Application Development, Apress