gpt4 book ai didi

google-app-engine - 持久对象列表

转载 作者:行者123 更新时间:2023-12-02 15:15:20 24 4
gpt4 key购买 nike

我懂了
“javax.jdo.JDOFatalUserException:don.Comment.id的元数据中发生错误:无法具有java.lang.String主键,并且不能成为子对象(拥有字段是don.Post.comments)。
NestedThrowables:“


运行grails + app-engine webapp时

我怎样才能解决这个问题?

class Comment.groovy

import javax.jdo.annotations.*;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
class Comment implements Serializable {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
String id

@Persistent(mappedBy="comments")
Post post

@Persistent
String name

@Persistent
String email

@Persistent
String url

static constraints = {
id( visible:false)
}
}

class Post.groovy
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
class Post implements Serializable {

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Long id

@Persistent
String title

@Persistent
String content

//static hasMany = [comments:Comment]

@Persistent(defaultFetchGroup = "true")
Comment comments

static constraints = {
id( visible:false)
}
}

最佳答案

对于子类,主键必须是com.google.appengine.api.datastore.Key值(或编码为字符串),请参见http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys

关于google-app-engine - 持久对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2063467/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com