我有一个名为
public class MyObject {
@ElementCollection
Map<Integer, AnotherJavaObject> customMap;
}
public class AnotherObject {
String value;
int value;
}
这有可能和冬眠一起痛吗?另一个对象是实体吗?
类MyObject中的映射应该是什么?
读完后,我给另一个物体作了如下注解
@Entity(name = "AnotherObject")
public class AnotherObject {
@ManyToOne
Myobject myObject;
}
And in the MyOBject class created a @OneToMany mappng as
@OneToMany(mappedBy="myObject)
AnotherObject anotherObject;
但这让我犯了个错误
org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: MyObject.anotherObject
所以我通过注册类克服了这个错误,但是我在合并时遇到了这个错误
object references an unsaved transient instance - save the transient instance before flushing: