I am using spring data jpa. I am using InheritanceType.JOINED for my inheritance strategy. Say I have the following entity relationships:
Animal (abstract class)
Cow extends Animal
Pig extends Animal
Cat extends Animal
etc..
Each animal has a "TYPE" column populated with the name of the class.
How would I query for some subset of animal types without joining every subclass table? For example, if I wanted to retrieve all cows and pigs but not any cats.
I have tried @Query("select a from Animal where a.type in (Cow, Pig)")
, but this will still perform a LEFT JOIN on the Cat table which is undesirable.
Is there some workaround for this?