我在休眠状态下遇到了这个问题:
Caused by: java.lang.IllegalArgumentException: org.hibernate.ObjectDeletedException: deleted instance passed to merge: [es.melit.celimac.domain.Alzado#<null>]
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:888)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:869)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298)
at com.sun.proxy.$Proxy239.merge(Unknown Source)
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:511)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:515)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:500)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:477)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 174 common frames omitted
当我尝试保存实体“ Alzado”时出现此错误
“ Alzado”与“ Edificio” oneToMany有关系:
Edificio.java
@OneToMany(mappedBy = "edificio", fetch = FetchType.EAGER)
@JsonIgnore
private Set<Alzado> alzados = new HashSet<>();
Alzado.java
@Entity
@Table(name = "alzado")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Alzado implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "codigo")
private String codigo;
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "edificio_id")
private Edificio edificio;
@Column(name = "archivo")
private String archivo;
@OneToMany(mappedBy = "alzado", fetch = FetchType.EAGER)
@JsonIgnore
private Set<Modulo> modulos = new HashSet<>();
/* GETTERS AND SETTERS */
我尝试将cascade = CascadeType.MERGE放进去,什么也没有,我也尝试过 级联= {CascadeType.MERGE,CascadeType.PERSIST} 而且行不通。我不知道还有什么尝试...
谢谢