Gae Cloud Services-Data storage (i)

Source: Internet
Author: User

The following is from the GAE_GWT Introductory guide, and I just did my study notes.


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{


@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 ()

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 ();
	  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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.