エラーとその解決

プログラミングをしていると色々とエラーに遭遇します。ちょっとまとめてみました。

Cannot have a java.lang.Long primary key and be a child object (owning field is xxxxx).

one-to-manyの関連を定義している際のエラー。
many側のオブジェクトのidはKey型を使わないといけない。
http://code.google.com/intl/ja/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys

java.lang.ClassCastException: com.google.appengine.api.datastore.Key

one-to-manyの関係にあるオブジェクトはListで型宣言されていると思いますが、このリストに新たなオブジェクトを追加すると発生した。
所有者側のidもKeyにすれば解決
http://groups.google.com/group/google-appengine-java/browse_thread/thread/af40582fa259fa56?pli=1

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.

one-to-manyの関連において、many側のオブジェクトを取得しようとしたが、まだindexが出来ていないため起こった模様。
管理ツールのIndexesのところを見てみると、Building...になっていた。
翌日確認してみたらServing...に変わっており、普通にアクセスできた。

The class "xxxx" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.

エンハンサ関連のエラー。
Eclipseの自動ビルドをとめていたから起きた。自動ビルドにしていれば、Google App Engine for Eclipseが自動で処理を行ってくれる。
http://code.google.com/intl/en/appengine/docs/java/datastore/usingjdo.html#Enhancing_Data_Classes