我有两个实体DealEntity
,DealTypeEntity
它们是相关的——
@Entity
class DealEntity{
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "DEAL_TYPE_ID")
private DealTypeEntity dealTypeEntity;
}
我试图通过创建包含 DealTypeEntity ref 的 DealEntity 实例来保存。
我正在使用 JPA,它给了我例外entityManager.persist(entity)
Oct 17, 2013 3:36:34 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [/Travel-Portal] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException:org.hibernate.TransientPropertyV alueException: object references an unsaved transient instance - save the transient instance before flushing: training.impetus.tp.model.DealEntity.dealTypeEntity -> training.impetus.tp.model.DealTypeEntity; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing: training.impetus.tp.model.DealEntity.dealTypeEntity -> training.impetus.tp.model.DealTypeEntity] with root cause
org.hibernate.TransientPropertyValueException: object references an unsaved transient i nstance - save the transient instance before flushing: training.impetus.tp.model.DealEntity.dealTypeEntity -> training.impetus.tp.model.DealTypeEntity
at org.hibernate.engine.spi.CascadingAction$8.noCascade(CascadingAction.java:380)
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:176)
at o rg.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEv entListener.java:160)
at o rg.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlus hingEventListener.java:151)
at o rg.hiborg.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:151)
at org.hib