Actually the problem is with your mapping. You either use @MappedSuperclass
or @Inheritance
. Both together don't make sense. Change your entity to:
@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class Animal {}
Don't worry, the underlying database scheme is the same. Now one, general AnimalRepository
will work. Hibernate will do the introspection and find out which table to use for an actual subtype.