迁移到appengine平台上

appengine是google的云计算平台,目前支持java, python语言开发网站等程序。我准备把最近开发的一个web迁移到appengine上面。这里记录所碰到的问题。

 

系统采用JPA + spring annotation transaction  + spring annotation MVC作为框架。

 

1。 enitity id

以前采用Integer作为enitity id,现在迁移appengine需要使用Long类型。

从跨平台的角度考虑,gae要求对象必须属于一个对象组,这样子对象使用String作为id。如果使用Hibernte +mysql平台的时候,必须使用uuid方式生成主健。可以参见如下的文章:http://xiaogui9317170.iteye.com/blog/283526

 

2。 JPQL query string

由于以前使用 hibernate + JPA,因此查询语句使用HQL是没有问题的。比如 'from User u'; 但是appengine使用标准的JPA, 应当修改为'select u from User u'。

 

3。eager loading 不支持

Child objects are loaded from the datastore when they are accessed for the first time. If you do not access the child object on a parent object, the entity for the child object is never loaded. (The datastore interface does not support the "eager" loading of child objects. The datastore does not support join queries, so an implementation of eager loading wouldn't save the app a call to the datastore.)

 

4。关联关系

A relationship between persistent objects can be described as owned, where one of the objects cannot exist without the other, or unowned, where both objects can exist independently of their relationship with one another.

The child class must have a key field whose type can contain the parent key information: either a Key, or a Key value encoded as a string.

App Engine does not support join queries: you cannot query a parent entity using an attribute of a child entity. (You can query a property of an embedded class, because embedded classes store properties on the parent entity

 

5。Spring框架

通过实验发现,spring2.5由于依赖了Javax.naming包而无法在GAE环境中运行正常。参考了GAE issue1240里面的方法,系统终于能正常运行,但是entityManager无法通过spring的@PersistContext设置成功。最后全部采用spring3后系统终于能正常运行。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值