Modified: websites/production/db/content/jdo/newshistory.html ============================================================================== --- websites/production/db/content/jdo/newshistory.html (original) +++ websites/production/db/content/jdo/newshistory.html Tue Jan 15 06:29:01 2013 @@ -1,16 +1,259 @@ -Java Data Objects (JDO) - News

Older JDO News

-JDO code donated to Apache by Sun Microsystems, Inc. -

On 9-Mar-2005 Sun Microsystems, Inc. officially donated + + + + + + Maven - + News + + + + + + + + +

+ +
+ +
+
+
+ + + + +

Older JDO News

+ +

+JDO code donated to Apache by Sun Microsystems, Inc. +

+

On 9-Mar-2005 Sun Microsystems, Inc. officially donated to Apache Software Foundation the intellectual property known as Java Data Objects, v. 1.0.2 and successors thereto to the extent provided by Sun. -

+

+

This was accomplished via Schedule B-2 to the Software Grant and Corporate Contributor License Agreement (CCLA) between The Apache Software Foundation and Sun Microsystems, Inc. -


\ No newline at end of file +

+
+ + + +
+
+
+
+
+ + + Modified: websites/production/db/content/jdo/object_retrieval.html ============================================================================== --- websites/production/db/content/jdo/object_retrieval.html (original) +++ websites/production/db/content/jdo/object_retrieval.html Tue Jan 15 06:29:01 2013 @@ -1,27 +1,239 @@ -Java Data Objects (JDO) - JDO Object Retrieval

Object Retrieval

+ + + + + + Maven - + JDO Object Retrieval + + + + + + + +

+ +
+ +
+
+
+ + +

Object Retrieval

+

JDO provides persistence of objects. The logical next step after persisting objects is to retrieve them for use in your application. There are several ways to do this -

Retrieve an object from its identity

+

+ +

Retrieve an object from its identity

+

The simplest form of object retrieval is where we have the identity. This is simply

-
+                
 Object obj = pm.getObjectById(identity);
                 
-

+

If the object is in the JDO cache then it is retrieved from there, otherwise the JDO implementation goes to the datastore. When the object is retrieved its fields are populated according to its Fetch Group. -

Retrieve an object based on its Extent

+

+
+ +

Retrieve an object based on its Extent

+

A persistable class can be persisted with an Extent of all instances of that type. You can use this to retrieve objects of the required type, like this

-
+                
 Extent ex = pm.getExtent(MyClass.class, true);
 Iterator iter = ex.iterator();
 while (iter.hasNext())
@@ -29,33 +241,59 @@ while (iter.hasNext())
     MyClass obj = (MyClass)iter.next();
     ...
 }
-

+

The second argument in the getExtent call is whether to include instances of subclasses. -



Retrieve an object based on a criteria

+

+
+
+ +

Retrieve an object based on a criteria

+

Where we want to retrieve all objects based on some criteria (e.g all objects of class A where field 'x' of A is a certain value) we need to use a query language. JDO2 provides 2 options here. JDOQL is object-based and allows you to express your query in terms of the classes and fields you are using. SQL is datastore-based and allows you to express your query in terms of the datastore tables and columns. -

+

+

To give an example of a JDOQL query

-
-Query q = pm.newQuery(MyClass.class, "field1 < value");
-q.declareParameters("int value");
+                
+Query q = pm.newQuery(MyClass.class, "field1 < value");
+q.declareParameters("int value");
 List results = q.execute(205);
 Iterator iter = results.iterator();
 while (iter.hasNext())
 {
     MyClass obj = (MyClass)iter.next();
 }
-

+

If the objects found by the query are in the JDO cache then they are retrieved from there, otherwise the JDO implementation goes to the datastore. When the objects are retrieved their fields are populated according to the Fetch Group. -


\ No newline at end of file +

+
+
+ + + +
+
+
+
+
+ + + Modified: websites/production/db/content/jdo/orm_dtd.html ============================================================================== --- websites/production/db/content/jdo/orm_dtd.html (original) +++ websites/production/db/content/jdo/orm_dtd.html Tue Jan 15 06:29:01 2013 @@ -1,36 +1,276 @@ -Java Data Objects (JDO) - ORM DTD

Meta-Data - ORM

- JDO2 defines XML MetaData in jdo files as well as orm files. + + + + + + Maven - + ORM DTD + + + + + + + +

+ +
+ +
+
+
+ + +

Meta-Data - ORM

+

+ JDO defines XML MetaData in jdo files as well as orm files. As always with XML, the metadata must match the defined DTD/XSD for that file type. - This section describes the content of the orm files. - The content of jdo files can be found here. - All orm files must contain a valid DTD/DOCTYPE specification. You can use PUBLIC or SYSTEM versions of these. -

- Here are a couple of examples valid for orm files with DTD specification + This section describes the content of the orm files. + The content of jdo files can be found here. + All orm files must contain a valid DTD/DOCTYPE specification. You can use PUBLIC or SYSTEM versions of these.

-
+            

+ Here are a couple of examples valid for orm files with DTD specification +

+
 <!DOCTYPE orm PUBLIC
-    "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.0//EN"
-    "http://java.sun.com/dtd/orm_3_0.dtd">
+    "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.0//EN"
+    "http://java.sun.com/dtd/orm_3_0.dtd">
 
 
-<!DOCTYPE orm SYSTEM "file:/javax/jdo/orm.dtd">
-

- Here is an example valid for orm files with XSD specification +<!DOCTYPE orm SYSTEM "file:/javax/jdo/orm.dtd">

+
+

+ Here is an example valid for orm files with XSD specification

-
-<?xml version="1.0" encoding="UTF-8" ?>
-<orm xmlns="http://java.sun.com/xml/ns/jdo/orm"
-     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-     xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/orm
-        http://java.sun.com/xml/ns/jdo/orm_3_0.xsd">
+            
+<?xml version="1.0" encoding="UTF-8" ?>
+<orm xmlns="http://java.sun.com/xml/ns/jdo/orm"
+     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/orm
+        http://java.sun.com/xml/ns/jdo/orm_3_0.xsd">
     ...
 </orm>
-

- Your MetaData should match either the DTD - or the XSD specification. -


\ No newline at end of file +

+ Your MetaData should match either the DTD + or the XSD specification. +

+ +
+ + +
+
+
+
+
+ + + Modified: websites/production/db/content/jdo/pm.html ============================================================================== --- websites/production/db/content/jdo/pm.html (original) +++ websites/production/db/content/jdo/pm.html Tue Jan 15 06:29:01 2013 @@ -1,27 +1,237 @@ -Java Data Objects (JDO) - Persistence Manager

Persistence Manager

- Any JDO-enabled application will require at least one PersistenceManager (PM). + + + + + + Maven - + Persistence Manager + + + + + + + +

+ +
+ +
+
+
+ + +

Persistence Manager

+

+ Any JDO-enabled application will require at least one PersistenceManager (PM). This is obtained from the PersistenceManagerFactory for the datastore. -

- The simplest way of creating a PersistenceManager - +

+

+ The simplest way of creating a PersistenceManager + is as follows

-
+            
 PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props);
 PersistenceManager pm = pmf.getPersistenceManager();
-

+

A PersistenceManager is the key to all persistence operations in JDO. With it you can persist, update, delete, and retrieve objects from the datastore. A PersistenceManager has a single transaction. -



Persist Objects

+

+
+ +

Persist Objects

+

To persist an object, the object must first be marked as persistable using MetaData (XML/Annotations). Then you would start the PM transaction, and use makePersistent as follows

-
+                
 PersistenceManager pm = pmf.getPersistenceManager();
 Transaction tx = pm.currentTransaction();
 try
@@ -51,26 +261,32 @@ finally
     }
     pm.close();
 }
-

- The makePersistent method of PersistenceManager makes the object persistent in - the datastore, and updates the 'state' of the object from Transient (at the start) - to Hollow (after commit() of the transaction). -

+

+ The makePersistent method of PersistenceManager makes the object persistent in + the datastore, and updates the 'state' of the object from Transient (at the start) + to Hollow (after commit() of the transaction). +

+

When an object is persisted, if it has any other objects referenced from that object they - also will be made persistent. This is referred to as persistence-by-reachability. + also will be made persistent. This is referred to as persistence-by-reachability. The main benefit of this is that if you have an object graph to persist, then you don't - need to call makePersistent() on all objects, instead just using one that can be - used to find all of the others. persistence-by-reachability is also run at the time of - calling commit() on the transaction. This has the effect that if you had called - makePersistent() on an object and that had persisted another object, and before - commit you had removed the relation to this other object, then at commit() the + need to call makePersistent() on all objects, instead just using one that can be + used to find all of the others. persistence-by-reachability is also run at the time of + calling commit() on the transaction. This has the effect that if you had called + makePersistent() on an object and that had persisted another object, and before + commit you had removed the relation to this other object, then at commit() the reachability algorithm will find that this other object is no longer reachable and will remove it from persistence. -



Retrieve Objects

+

+
+
+ +

Retrieve Objects

+

So we've made some of our objects persistent, and now we want to retrieve them in our application. Here's one way of retrieving objects of a particular type.

-
+                
 tx = pm.currentTransaction();
 try
 {
@@ -93,15 +309,20 @@ catch (Exception e)
         tx.rollback();
     }
 }
-

- The Extent interface is one of the ways to retrieve your objects. - The others use the Query interface, allowing more precise filtering over the +

+ The Extent interface is one of the ways to retrieve your objects. + The others use the Query interface, allowing more precise filtering over the objects returned. -



Update Objects

+

+
+
+ +

Update Objects

+

To update an object we firstly retrieve it, as above, and then we call any of its mutator methods. For example

-
+                
 tx = pm.currentTransaction();
 try
 {
@@ -125,13 +346,18 @@ catch (Exception e)
         tx.rollback();
     }
 }
-

+

When setValue() is called on the persistent object this change is intercepted by JDO and the value change will be automatically sent to the datastore ... transparently! -



Delete Objects

+

+
+
+ +

Delete Objects

+

So we can persist objects, and retrieve them. Now we want to remove one from persistence.

-
try
+                
try
 {
     tx = pm.currentTransaction();
     tx.begin();
@@ -149,14 +375,18 @@ catch (Exception e)
         tx.rollback();
     }
 }
-

Making an object transient

+
+

+ +

Making an object transient

+

As we have seen in the JDO States guide, an object can have many possible states. When we want to take an object and work on it, but removing - its identity we can make it transient. This means that it will retain the values + its identity we can make it transient. This means that it will retain the values of its fields, yet will no longer be associated with the object in the datastore. We do this as follows

-
try
+                
try
 {
     tx = pm.currentTransaction();
     tx.begin();
@@ -175,7 +405,25 @@ catch (Exception e)
     }
 }
 
-... (code to work on "my_obj")
-

\ No newline at end of file +... (code to work on "my_obj")
+
+
+ + +
+
+
+
+
+ + +