Using Datastore with JDO 1. Setting up DataNucleus Access Platform 2. JDO class enhancement 3. POJOs and JDO Annotations 4. PersistencyManager and its.

Slides:



Advertisements
Similar presentations
Behzad Samin 0 An End-to-End Overview of a RESTful Web Service.
Advertisements

MANIPULATING DATA
Persistence Models Margaret Smith. Overview Java Data Objects (JDO) Enterprise Java Beans (EJB) 3.0 Demos and code.
1 The Properties Pattern Based on
The Properties Pattern
Format PDF The tools used by esup-helpdesk developers: Eclipse, Omondo EclipseUML plugin, Apache OJB JDO Pascal Aubry & Alexandre Boisseau IFSIC – University.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Java Data Object Che-Rung Lee. JDO Objectives Transparent persistence Range of implementations  embedded (J2ME)  two tier (J2SE)  enterprise (J2EE,
Session-02.
Google AppEngine. Google App Engine enables you to build and host web apps on the same systems that power Google applications. App Engine offers fast.
By: Devesh Sharma.  Why Cloud Computing? ◦ Traditional Business Applications  Expensive  Complicated  Difficult to manage  Idea behind Cloud Computing.
Google App Engine Danail Alexiev Technical Trainer SoftAcad.bg.
An Introduction to Hibernate Matt Secoske
The Java Persistence API Edel Sherratt. Contents Revisit applications programming Using Java Persistence API.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
Object Persistence and Object-Relational Mapping James Brucker.
Introduction Servlets and JSP Celsina Bignoli
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
Prof. A.R. Rele. What Is Google App Engine? Google App Engine lets users run web applications on Google's infrastructure. App Engine applications are.
Agenda What is Hibernate Spring Integration Questions Overview
BEST PRACTICES - Java By Configuration Use global-forwards/results Helps to avoid duplicate jsp files and redundancy forward mapping.
Eclipse – making OOP Easy
PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented.
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
© 2012 Autodesk Implementing Cloud-Based Productivity Solutions with the AutoCAD® ObjectARX® API Ravi Krishnaswamy Senior Software Architect.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
MCS 270 Spring 2014 Object-Oriented Software Development.
Running Servlets JSDK2.1 default.cfg : Web Server configuration information batch files to start and stop server Servlet properties in /webpages/WEB-INF.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
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.
JBoss at Work Databases and JBoss Chapter 4 Jeff Schmitt October 26, 2006.
Threading Servlets Can handle multiple clients concurrently Shared resources must be synchronized or create a servlet that handles one request at a time.
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.
Reporting – Sort Orders, Selections, and Related Data TEC02 Brian Ciccolo.
Topic : Hibernate 2: Object Persistence and ORM Kaster Nurmukan.
(1) Introduction to Models using the Play Framework Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University.
Ganymede Simultaneous Release | © 2008 by Springsite B.V., The Netherlands made available under the EPL v1.0 Teneo Ganymede Simultaneous Release.
July 7-11, 2003  Portland, Oregon JDO (Java Data Objects) What It Is And Why It Matters Ron Hitchens JavaPolis.
MCS 270 Spring 2014 Object-Oriented Software Development.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
The Data Access Object Pattern (Structural – Not a GoF Pattern) ©SoftMoore ConsultingSlide 1.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
Hibernate Thuy, Le Huu. Pentalog VN. Agenda Hibernate Annotations Improving performance – Lazy loading – Fetching Strategies – Dynamic insert, dynamic.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2.
Hibernate Java Persistence API. What is Persistence Persistence: The continued or prolonged existence of something. Most Applications Achieve Persistence.
Google App Engine using Java 1. Outline Getting started Guestbook example Todo example Simplified Madlib 2.
Platform as a Service (PaaS)
CONTENT MANAGEMENT SYSTEM CSIR-NISCAIR, New Delhi
Platform as a Service (PaaS)
Platform as a Service Applications
Google App Engine Danail Alexiev
Interface.
Applying OO Concepts Using Java
Teneo Ganymede Simultaneous Release Graduation Review
Teneo Ganymede Mini Deck
Introducing Scenario Network Data Editing and Enterprise GIS
ITE “A” GROUP 2 ENCAPSULATION.
Presentation transcript:

Using Datastore with JDO 1. Setting up DataNucleus Access Platform 2. JDO class enhancement 3. POJOs and JDO Annotations 4. PersistencyManager and its Factory 5. Creating and saving objects 6. JDOQL Queries

Setting up the system for JDO JDO is a spec (like JPA) for persistent objects. DataNucleus is a specific JDO implementation used by Google AppEngine (like Hibernate) To use it, jdoconfig.xml is created in the final WAR file Eclipse GAE plugin users: automatically. Manually – see rted/usingdatastore.html

JDO Class enhancement Automatic post-compilation step based on the annotations you add in your classes Allows more flexibility (transparent persistance : no need to change your classes) Links your classes and the actual JDO (DataNucleus) persistency providing layer

POJO and JDO annotations JDO spec supports persistency for plain java objects. JDO annotations: tags that tell JDO how to store/retrieve your objects Example.

@PersistenceCapable public class = IdGeneratorStrategy.IDENTITY) private Key private User private String private Date date; public Greeting(User author, String content, Date date) { this.author = author; this.content = content; this.date = date; } public Key getKey() { return key; } public User getAuthor() { return author; } public String getContent() { return content; } } 3 properties : author, content, date Private fields (important) + access through get/set functions !(why ?) JDO entity key is required Object  JDO NotPersistent Some field types are persistent by default (see DataNucleus manual) Inheritance, collections and most other intuitive stuff are supported by JDO. For esoteric situations, consult with DataNucleus manual Your object relationship will affect DB operations (cascade delete)

PersistencyManager and its Factory All datastore operations go through PersistencyManager which is accessed through a PersistencyManagerFactory PMF takes a long time to start – maintain a singleton instance over your application

package guestbook; public class SignGuestbookServlet extends HttpServlet { private static final Logger log = Logger.getLogger(SignGuestbookServlet.class.getName()); public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String content = req.getParameter("content"); Date date = new Date(); Greeting greeting = new Greeting(user, content, date); PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.makePersistent(greeting); } finally { pm.close(); } resp.sendRedirect("/guestbook.jsp"); } } The annotations and bytecode enhancement take it from there. Once makePersistent() returns, the new object is stored in the datastore.

JDOQL Queries Perform queries aboud JDO entities Use newquery() method of PersistencyManager to get a query obj. The execute() method of the query object runs the query and returns a List<> of results JDOQL is a subset of SQL. For more details, see manual Example follows:

PersistenceManager pm = PMF.get().getPersistenceManager(); String query = "select from " + Greeting.class.getName(); List greetings = (List ) pm.newQuery(query).execute(); if (greetings.isEmpty()) { %> The guestbook has no messages. An anonymous person wrote: wrote: <% } } pm.close();