Код: Выделить всё
@Data
@Builder
@Entity
@FieldDefaults(level = AccessLevel.PRIVATE)
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "refund_initiate",uniqueConstraints={@UniqueConstraint(columnNames={"device_code","installation_id"})})
public class RefundInitiate extends BaseEntity{
...
@EqualsAndHashCode.Exclude
@ToString.Exclude
@OneToMany(mappedBy = "refundInitiate")
List refundLogs;
}
@Data
@Builder
@Table(name = "refund_log")
@Entity
@NoArgsConstructor
@AllArgsConstructor
public class RefundLogs extends BaseEntity {
@EqualsAndHashCode.Exclude
@ToString.Exclude
@ManyToOne
@JoinColumn(name = "refund_initiate_id")
RefundInitiate refundInitiate;
}
Код: Выделить всё
@Override
public Boolean approveRefund(Integer refundId) {
Optional refundInitiateOpt = refundInitiateRepo.findById(refundId);
if (refundInitiateOpt.isEmpty())
return false;
RefundInitiate refundInitiate = refundInitiateOpt.get();
// some logic here but haven't touched the `RefundLogs` at all
refundInitiateRepo.save(refundInitiate);
// some logic, again no changes on RefundLogs`
return true;
}
Код: Выделить всё
HibernateException: Found shared references to a collection: app.model.RefundInitiate.refundLogs] with root cause
org.hibernate.HibernateException: Found shared references to a collection: app.model.RefundInitiate.refundLogs
Код: Выделить всё
refundInitiateRepo.save(refundInitiate);
Код: Выделить всё
'org.hibernate:hibernate-envers:5.4.22.Final'
Пожалуйста, помогите мне узнать, как решить эту проблему, удаление сопоставления не поможет. потому что он где-то используется.
Я пробовал использовать Cascade в качестве PERSIT, но не помогло.
Подробнее здесь: https://stackoverflow.com/questions/792 ... erences-to