Anyway, 在GAE上儲存資料必須要使用JDO或JPA這兩種標準, 所以我今天花了點時間研究一下, Google上是採用 Datanucleus的solution, 但這時還不曉得這個solution是甚麼, 接著上網查到 http://en.wikipedia.org/wiki/Datanucleus中有這一段: DataNucleus Access Platform is the persistence layer behind Google App Engine for Java. 原來這個 plateform同時支援JDO跟JPA兩個標準, 因此想用哪個就用哪個囉.
另外也看到Hibernate主要是JPA的實作, 因此若使用JPA可算是有摸蜆仔兼洗褲的作用. 以後若有機會使用Hibernate的話, 不妨就使用JPA來儲存資料吧.
不過看到以下那一堆unsupported features... 很多features我看不太懂是甚麼意思, 不過不能join不能aggregrate?! 不會吧~~ 那我要資料總筆數怎麼作咧... 還是說有method可以用? 看來只好等空間拿到手再來好好試用一下.
Edit 1: 剛又多研究了一下, 知道資料總筆數要用 datastore.prepare(query).countEntities()來取得, 也就是說, 基本上資料應該已經全部從資料庫給拉出來了, 這樣若有需要作報表系統的話, 效能堪慮阿...
Unsupported Features of JDO
The following features of the JDO interface are not supported by the App Engine implementation:
- Unowned relationships. You can implement unowned relationships using explicit Key values. JDO's syntax for unowned relationships may be supported in a future release.
- Owned many-to-many relationships.
contains()
syntax for query filters on Collection fields. You can test that a multi-valued property (a Collection field) has a value using an equality filter:collection == "value"
- "Join" queries. You cannot use a field of a child entity in a filter when performing a query on the parent kind. Note that you can test the parent's relationship field directly in query using a key.
- JDOQL grouping and other aggregate queries.
- Polymorphic queries. You cannot perform a query of a class to get instances of a subclass. Each class is represented by a separate entity kind in the datastore.
IdentityType.DATASTORE
for the@PersistenceCapable
annotation. OnlyIdentityType.APPLICATION
is supported.- There is currently a bug preventing preventing persistent fields on superclasses from being saved to the datastore. This will be fixed in a future release.
Unsupported Features of JPA
The following features of the JPA interface are not supported by the App Engine implementation:
- Owned many-to-many relationships, and unowned relationships. You can implement unowned relationships using explicit Key values, though type checking is not enforced in the API.
- "Join" queries. You cannot use a field of a child entity in a filter when performing a query on the parent kind. Note that you can test the parent's relationship field directly in query using a key.
- Aggregation queries (group by, having, sum, avg, max, min)
- Polymorphic queries. You cannot perform a query of a class to get instances of a subclass. Each class is represented by a separate entity kind in the datastore.
沒有留言:
張貼留言