2009-09-01 5 views
1

googleアプリケーションエンジン(java)に付属しているゲストブックの例を、「自己結合」のような親子関係を含むように変更しました。googleアプリケーションエンジンでの自己参加

今私のgreeting.javaファイルはこの

package guestbook; 

import java.util.Date; 
import java.util.List; 

import javax.jdo.annotations.IdGeneratorStrategy; 
import javax.jdo.annotations.IdentityType; 
import javax.jdo.annotations.PersistenceCapable; 
import javax.jdo.annotations.Persistent; 
import javax.jdo.annotations.PrimaryKey; 

import com.google.appengine.api.datastore.Key; 
import com.google.appengine.api.users.User; 

@PersistenceCapable(identityType = IdentityType.APPLICATION) 
public class Greeting { 
    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private Key id; 

    @Persistent 
    private User author; 

    @Persistent 
    private String content; 

    @Persistent 
    private Date date; 

    @Persistent 
    private Greeting parent; 

    @Persistent(mappedBy="parent") 
    private List<Greeting> children; 

    public Greeting getParent() { 
     return parent; 
    } 

    public void setParent(Greeting parent) { 
     this.parent = parent; 
    } 

    public List<Greeting> getChildren() { 
     return children; 
    } 

    public void setChildren(List<Greeting> children) { 
     this.children = children; 
    } 

    public Greeting(User author, String content, Date date) { 
     this.author = author; 
     this.content = content; 
     this.date = date; 
    } 

    public Key getId() { 
     return id; 
    } 

    public User getAuthor() { 
     return author; 
    } 

    public String getContent() { 
     return content; 
    } 

    public Date getDate() { 
     return date; 
    } 

    public void setAuthor(User author) { 
     this.author = author; 
    } 

    public void setContent(String content) { 
     this.content = content; 
    } 

    public void setDate(Date date) { 
     this.date = date; 
    } 
} 

は予告親と子フィールドの追加、およびcom.google.appengine.api.datastore.Keyに主キーのタイプを変更する(などのように見えますhttp://code.google.com/appengine/docs/java/datastore/relationships.html#Owned_One_to_Many_Relationshipsに表示)

データストアにデータを保存しません。私は理由を理解していない。私はローカルデータストアとインデックスファイルを削除しようとしましたが(Web上のどこかで述べたように)、動作しません。例外はありません。

誰かがそれに見ることができると

答えて