14
Given the following classes:
@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
@DiscriminatorColumn(name="animalType",discriminatorType=DiscriminatorType.STRING)
@QueryExclude
public abstract class Animal {}
@Entity
@DiscriminatorValue("dog")
public class Dog {}
@Entity
@DiscriminatorValue("cat")
public class Cat {}
Is it possible somehow to configure a JPA Repository for Animal?
I've tried
public interface AnimalRepository extends JpaRepository<Animal,Long>
However this fails with:
java.lang.IllegalArgumentException: Not an managed type: Animal
Is there a way to configure this?
I'd like to be able to perform tasks like:
@Autowired
private AnimalRepository repository;
public void doSomething()
{
Animal animal = repository.findById(123);
animal.speak();
}