Google App Enginでぶち当たった問題 その1
ここ1週間ほどGAEを利用してアプリケーションを開発しているのだが、馴れた環境ではないので試行錯誤しながらアプリを実装している。
今回僕がいくつかぶち当たった問題を記録として書き留めます。
みなさんも同じ問題に当たるかもしれないので参考まで。
とりあえず今作っているアプリの大まかな開発環境は以下の通り
1.Google API Libraries for Google Web Toolkit のGoogle Maps 1.0 Library 1.0
http://code.google.com/docreader/#p=gwt-google-apis&s=gwt-google-apis&t=MapsGettingStarted
2. Google Web Toolkit 1.6.2
http://code.google.com/webtoolkit/
3. Google App Engine
http://code.google.com/appengine/
4. Eclipse 3.4
アプリは以下の構成
GUI(GWT)<----RPC通信--->GEA(servlet)<--JPA-->The Google App Engine datastore
GEAのでアプリを動かすためにいろいろと制約がいろいろとある。
http://code.google.com/appengine/docs/java/runtime.htmlでは
- A Java application cannot create a new java.lang.ThreadGroup nor a new java.lang.Thread.=スレッドが作成できない
- A Java application cannot use any classes used to write to the filesystem, such as java.io.FileWriter. ファイル書き込みができない。
- Features of the java.lang.System class that do not apply to App Engine are disabled.
java.lang.System関連は使えません。
GoogleでJavaの実装に手が加えられています。ですので以下の実行可能なクラス一覧を確認する必要があるかとおもいます。
http://code.google.com/appengine/docs/java/jrewhitelist.html
またデータの保存先であるデータベースも癖があります。
JDBCは使えない。JPAおよびJDOのみサポート、しかもデータ構造も特殊
http://code.google.com/appengine/docs/java/datastore/dataclasses.htmlのCore Value Typeに使えるデータタイプが記載されています。
今回JPAでアプリを実装するのですがまたまた制約あり。
参照先:
http://code.google.com/appengine/docs/java/datastore/usingjpa.html
Unsupported Features of JPA
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.
何とか設計でカバーしなければいけない部分が多くあるかと思います。