У меня есть эта проблема с hibernate:
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 */
Я пытался поставить каскад = CascadeType.MERGE и ничего, я тоже пытался каскад ={CascadeType.MERGE, CascadeType.PERSIST} и не работает.Я не знаю, что попробовать еще ...
Спасибо