2009-09-01 30 views
1

我已經修改了谷歌應用程序引擎(Java)附帶的留言板示例,使用某種'自我加入'來包含父子關係。自我加入谷歌應用程序引擎(java)

現在我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所示)

現在它不會將數據保存到數據存儲區。我不明白爲什麼。我試圖刪除本地數據存儲和索引文件(如網上說的),但它不會工作。沒有例外,沒有。

有人可以查看一下,請大家幫忙

回答