Приложение Springboot не начинается, когда я использую @Audited (targetAuditMode = incomeleTargetAuditMode.not_audited)JAVA

Программисты JAVA общаются здесь
Anonymous
Приложение Springboot не начинается, когда я использую @Audited (targetAuditMode = incomeleTargetAuditMode.not_audited)

Сообщение Anonymous »

У меня есть 2 Entisemente и Address < /p>
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Audited
public class Employee implements Serializable {
private static final long serialVersionUID = 2816053548465680155L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long employeeId;
private String name;
private String designation;
private Double salary;
@OneToMany(mappedBy = "employee", cascade = CascadeType.ALL)
@JsonManagedReference
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private List addresses;

public EmployeeDTO toDTO() {
EmployeeDTO dto = new EmployeeDTO();
dto.setEmployeeId(this.employeeId);
dto.setName(this.name);
dto.setDesignation(this.designation);
dto.setSalary(this.salary);
List addressDTOs = new ArrayList();
for (Address address : this.addresses) {
addressDTOs.add(address.toDTO());
}
dto.setAddresses(addressDTOs);

return dto;
}
}
< /code>
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Address implements Serializable {
private static final long serialVersionUID = 2816053548965680155L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long addressId;
private String street;
private String city;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "employee_id")
@JsonBackReference
private Employee employee;

public AddressDTO toDTO() {
AddressDTO dto = new AddressDTO();
dto.setAddressId(this.addressId);
dto.setCity(this.city);
dto.setStreet(this.street);
return dto;
}
}
< /code>
Springboot application fail to stat with error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: An audited relation from com.example.employee_management.model.Employee.addresses to a not audited entity com.example.employee_management.model.Address! : origin(envers)
Based on the article i read we can use @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) on relations when we don't want to audit the specific relation details but only audit the Keys.
My question is how to use @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)?

Подробнее здесь: https://stackoverflow.com/questions/794 ... mode-relat

Вернуться в «JAVA»