The following is from the GAE_GWT Introductory guide, and I just did my study notes.
Overview:
The APP engine the data store to store objects (entities) and execute queries against them.
The data store can perform multiple operations in one transaction. Roll back the transaction if any operation fails, and applies to distributed network applications.
The difference between Gae data store and traditional relational database.
The data store is a distributed architecture management extension to a very large dataset. App Engine applications can describe the relationships between data objects.
And to define the index of the query to optimize how the data is distributed. The use of different data design and management methods, can take full advantage of the automatic extension function.
1, data storage process.
Define the data type---Get the interactive interface----> The last call to save the strength of the data type to the database in the interactive interface.
The Java SDK includes implementation data modeling and persistent processing data for Java Data Objects, JDO and Java Persistence API JPA interfaces.
JDO uses annotations to specify how class instances are stored as entities in the data store, and how to recreate an instance when an entity retrieves it from the data store.
@PersistenceCapable (identitytype=identitytype.application)
public class employee{
@PrimaryKey
@Persistent (Valuestrategy=idgenerator)
....... 101
}
Define the data type of an entity employee, and if you want to save the entity into the database, we need to be in Yo persistencemanagerfactory object.
Gets the PersistenceManager object to interact with the data store.
To ensure that only one instance of the program is captured in its lifecycle (which spans multiple queries), it is necessary to do this in a separate class of wrapping paper.
Import Javax.jdo.JDOHelper;
Import javax.jdo.PersistenceManagerFactory;
Public final class PMF {
private static final persistencemanagerfactory pmfinstance
= Jdohelper.getpersistencemanagerfactory ("Transactions optional");
Private PMF () {} public
static persistencemanagerfactory get ()
{return
pmfinstance
}
}
Finally, we can instantiate the strength of the data class and store it in the data store.
Employee Employee=new Employee ("Alfre", "Smith", New Date ());
PersistenceManager pm = Pmf.get (). Getpersistencemanager ();
Try
{
pm.makepersistent (employee);
} Finally
{
pm.close ();
}
JDO includes a query interface called JDOQL, and we can use JDOQL to retrieve an entity as an instance of this class, as follows:
String query = "SELECT from" +employee.class.getname () + "where lastname= ' smith+ '";
List<employee> employees= (list<employee>) pm.newquery (query). Execute ();