我懂了“javax.jdo.JDOFatalUserException:don.Comment.id 的元数据错误:不能有 java.lang.String 主键并且是子对象(拥有字段是 don.Post.comments)。
嵌套的Throwables:”
运行我的 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 http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)