简体   繁体   English

使用Google AppEngine和Objectify更改“模式”

[英]Changing 'schema' with Google AppEngine and Objectify

I am exploring web development with Google AppEngine (Java). 我正在使用Google AppEngine(Java)探索Web开发。 My application has a very basic data storage requirement that is well suited to AppEngine's 'map' like datastore. 我的应用程序有非常基本的数据存储要求,非常适合AppEngine的“地图”(如数据存储区)。

The basic unit is one class that will have member variables that will be written or read from the database per transaction (this is because it interacts with an Android app). 基本单元是一个类,它将具有成员变量,该成员变量将在每个事务中从数据库中写入或读取(这是因为它与Android应用程序交互)。

I am considering using Objectify for interfacing. 我正在考虑使用Objectify进行接口。

My questions are : What happens if I later change the size (number of variables) in my base class ? 我的问题是:如果以后更改基类的大小(变量数),会发生什么? I know AppEngine isn't typed but will Objectify cause any problems if some variables are available for some keys and not for others ? 我知道没有输入AppEngine,但是如果某些变量可用于某些键而不适用于其他键, Objectify是否会引起任何问题?

This is addressed extensively in the manual: 手册对此进行了详细介绍:

http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Migrating_Schemas http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Migrating_Schemas

The short answer is that you can add and remove fields at will. 简短的答案是您可以随意添加和删除字段。 In addition, there are facilities for more sophisticated transformations of data. 此外,还有用于更复杂的数据转换的工具。

If you decide to move from the Objectify framework to the Low-level API later, you won't have a problem. 如果您决定稍后从Objectify框架移至低级API,则不会有问题。 App engine's datastore is typed, but not with all the Java types. App Engine的数据存储区已键入,但不是所有Java类型。 I don't know whether you'd be able to get JDO or JPA to work without reading and re-writing all your data, but I think you probably would. 我不知道您是否能够在不读取和重写所有数据的情况下使JDO或JPA正常工作,但是我想您可能会这样做。

Objectify 4's method of storing a Map is pretty nice - storing properties as something like "fieldname-mapkey" Objectify 4的存储地图的方法非常好-将属性存储为“ fieldname-mapkey”之类的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM