开发者

Google App Engine JPA + Objectify

I have a Java + GAE + JPA proj开发者_Python百科ect and I want introduce Objectify framework to as well as I have JPA, so my question: is it possible to combine JPA (EntityManager, JPQL etc...) with Objectify in cases where I need it? Have anybody such experience?

I mean I want to have a DAO which manipulates with EntityManager and ObjectifyService as well


The simple answer is yes, you can have both at the same time. The mapping of JPA entities to Objectify entities is "as you would expect" - fields have the same names, etc.

It gets a little more complicated if you use advanced Objectify features like embedded classes and polymorphism - but even these can be mapped in JPA. The Objectify documentation describes the native storage format for these features.

Be careful about doing this, however. Objectify is very forgiving of incoherent data - a convenient feature when making schema changes. But if you, for example, forget to add a field to your Objectify entity and then use Objectify to load/save the entity, you will effectively "strip off" the forgotten field. Parallel entity classes must be maintained carefully.


Yes you can, but why? In the case of transition from JPA to Objectify it is reasonable but I wouldn't suggest anything outside that scope.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜