Databases Reference
In-Depth Information
JDOHelper.getPersistenceManagerFactory(“transactions-optional”);
private PMF() {}
public static PersistenceManagerFactory get() {
return pmfInstance;
}
}
jtaskmanager GAE project
Finally, you can save an object as follows:
String name = “task1”;
String description = “a task”;
Date startDate = new Date();
String status = “task created”;
Available for
download on
Wrox.com
Task task = new Task(name, description, startDate, status);
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(task);
} finally {
pm.close();
}
jtaskmanager GAE project
Then you can query for all tasks using the JDO Query Language (JDOQL), which is similar to
GQL, like so:
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = “select from “ + Task.class.getName();
List<Task> tasks = (List<Task>) pm.newQuery(query).execute();
Available for
download on
Wrox.com
jtaskmanager GAE project
The use of JDO and JPA (which is not illustrated in this chapter) bridge the gap between the
typical object-centric application development and a scalable ordered and sorted column-family
store like GAE's data store. They help developers leverage the app engine's scalable environment
without the necessity to learn a completely new database technology. However, one must keep
in mind that the JDO and JPA that apply to the app engine are just a subset of the
overall specifi cation.
All that was explained about the queries, their behavior, and their limitations remains the same,
whether used with the Python or the Java SDK. Also, indexes and transactional capabilities and
concepts remain the same.
Next, I explore Amazon SimpleDB.