【发布时间】:2014-09-15 12:54:52
【问题描述】:
我有一个休眠映射,
@Entity
@Table(name="user")
public class User{
@ManyToOne(optional=true)
@JoinColumn(name="email_id",nullable=true)
private Email email;
}
在我的映射中,Email 对象有时会为空。出现以下错误,因为 email_id 和 email 字段不为空,我只想在用户表上插入,如果对象为空,则需要跳过电子邮件表。我该如何处理这种情况?
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing
如果我使用 @ManyToOne(cascade=CascadeType.ALL), am getting null exception。
请帮助我,提前谢谢
【问题讨论】:
标签: hibernate jakarta-ee