【问题标题】:self join in google app engine (java)自我加入谷歌应用引擎(java)
【发布时间】:2010-11-24 17:43:19
【问题描述】:

我已经修改了谷歌应用引擎 (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所示)

现在它不会将数据保存到数据存储区。我不明白为什么。我曾尝试删除本地数据存储和索引文件(如网络上某处所述),但它不会工作。没有例外,什么都没有。

有人可以帮忙看看吗

【问题讨论】:

    标签: java google-app-engine jdo


    【解决方案1】:

    原来这是 Google App Engine 中的一个已知问题

    http://code.google.com/p/datanucleus-appengine/issues/detail?id=119

    现在我需要更改我的数据模型以使用 App Engine

    【讨论】:

      猜你喜欢
      • 2012-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 2012-02-12
      • 1970-01-01
      相关资源
      最近更新 更多