i'm using the @Where hibernate annotation to return users after a soft delete. I check the value of the "active" variable and it works fine if all users have active = true, while at least one of them has active = false, it returns an "EntityNotFoundException" exception. I wish it would only return cars with active users, rather than throwing an exception.
@Entity
@Table(name = "users")
@Getter
@Setter
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Where(clause = "is_active")
public class UserEntity {
@NotNull
@Column(unique = true)
@NaturalId
private Long id;
@Column(name = "is_active")
private boolean active;
@Entity
@Table(name = "user_cars")
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class CarEntity {
@Id
@GeneratedValue(strategy = IDENTITY)
@EqualsAndHashCode.Include
private Long id;
@NotNull
@ManyToOne(fetch = LAZY)
@JoinColumn(name = "user_id")
private UserEntity user;