I use Spring Data JPA and Hibernate trying to implement soft delete. All examples I seen are very simple where clauses like a boolean check. What I need is for example soft delete all dogs if their breed is in a list of banned breeds for example. I have a dynamic list:
List<String> bannedBreedsComesFromPropertiesFile = Arrays.asList("beagle", "terrier", "dalmation")
And repo:
public interface DogRepository extends CrudRepository<Dog, Integer> {
findAllBy....
findAllBy...
findAllBy...
....
}
So the breed filter should apply to all above findAll methods.
And then I want to achieve a soft delete/Filter with these dog breeds from DB:
@Entity
@Where(clause="breed != Not in list bannedBreedsComesFromPropertiesFile")
public class Dog{
@Column(name="breed")
private String breed;
}
How can I achieve this? I cant find the correct syntax if it exists.