我正被一个
org.hibernate.TransientObjectException使用Grails 2.3.9和Grails Hibernate 3插件3.6.10.15
具体问题如下:
我有一个名为Pencil的域类和一个具有多对多关系的域类Backpack:
Pencil{
PencilType type
Location location
Date creationDate
String description
int position
boolean active
static hasMany = [backpacks: BackPack]
static belongTo = [backpacks: BackPack]
static constraints = { .... all nullable ..... }
}
BackPack{
Color color
int size
static hasMany = [pencils: Pencil]
static belongsTo = [pencils: Pencil]
static constraints = { .... all nullable ..... }
}如果我创建并保存了一支铅笔,我不能在没有得到的情况下保存:
org.hibernate.TransientObject Exception
Message: object references an unsaved transient instance - save the transient instance before flushing: Pencil即使在创建空白铅笔对象时也会发生这种情况。
new Pencil().save()--UPDATE-- **同时使用Hibernate3和Hibernate4 Grails插件时出现问题。
发布于 2014-06-05 05:42:38
请尝试确保您已经为写操作正确地使用@Transactional或withTransaction划分了事务边界。
https://stackoverflow.com/questions/24047646
复制相似问题