Я пытаюсь применить условие where к связанной сущности, но набор результатов содержит все данные связанной сущности. Похоже, фильтр игнорируется. У меня есть следующие объекты:
Аудит объекта:
@Entity
@Table(name = "entity_audit")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@org.springframework.data.elasticsearch.annotations.Document(indexName = "entityaudit")
public class EntityAudit implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
private Long id;
@NotNull
@Column(name = "entity_id", nullable = false)
private Long entityId;
@NotNull
@Column(name = "entity_class_name", nullable = false)
private String entityClassName;
@NotNull
@Column(name = "entity_name", nullable = false)
private String entityName;
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "action_type", nullable = false)
private EntityAuditType actionType;
@NotNull
@Column(name = "timestamp", nullable = false)
private Instant timestamp;
@NotNull
@Column(name = "user", nullable = false)
private String user;
@NotNull
@Column(name = "transaction_uuid", nullable = false)
private String transactionUuid;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "entity_audit_id")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<EntityAuditUpdateData> entityAuditUpdateData = new HashSet<>();
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "entity_audit_id")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<EntityAuditStatus> entityAuditStatuses = new HashSet<>();
Getters and setters...
Статус аудита объекта
@Entity
@Table(name = "entity_audit_status")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@org.springframework.data.elasticsearch.annotations.Document(indexName = "entityauditstatus")
public class EntityAuditStatus implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@org.springframework.data.elasticsearch.annotations.Field(type = FieldType.Keyword)
private Long id;
@NotNull
@Column(name = "user_login", nullable = false)
private String userLogin;
@NotNull
@Column(name = "jhi_read", nullable = false)
private Boolean read;
@ManyToOne
private EntityAudit entityAudit;
Getters and setters...
Я пытаюсь выполнить этот запрос:
@Query("select distinct entityAudit from EntityAudit entityAudit " +
"join entityAudit.entityAuditStatuses entityAuditStatus " +
"where entityAuditStatus.userLogin =:userLogin " +
"order by entityAudit.timestamp desc")
Page<EntityAudit> retireveAllByUserLogin(@Param(value = "userLogin") String userLogin, Pageable pageable);
Но когда я получаю данные, EntityAuditStatuses не фильтруются. Я не могу понять, где проблема. Спасибо.