2 entities that I have: Country and User
@Entity(name = "Country")
@Table(name = "countries")
public class Country {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(cascade = CascadeType.ALL,
orphanRemoval = true)
private List<User> users = new ArrayList<>();
}
@Entity(name = "User")
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private boolean removed;
}
Entity User has an attribute, removedtype boolean and we need to skip/ignore all User's that have removed equals true.
Does Hibernate provide any suitable mechanism to achieving my goal?
P.S: Google says that potentially I can use annotations like: @JoinColumn, @JoinColumnOrFormula, but based on docs that I have read, annotations mentioned above belong to @ManyToOne scenario, in my particular case I have @OneToMany relation.