簡體   English   中英

自己加入谷歌應用引擎(java)

[英]self join in google app engine (java)

我修改了 google app engine (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

現在它不會將數據保存到數據存儲區。 我不明白為什么。 我試過刪除本地數據存儲和索引文件(如網上某處所說),但它不起作用。 沒有例外,沒有。

有人可以調查一下,請幫忙

事實證明這是 Google App Engine 中的一個已知問題

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

現在我需要更改我的數據模型以使用 App Engine

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM