I am using single table inheritance strategy. I want to perform a search in the database by filtering it using the discriminator type. How am I to write a function in JPA to perform this operation.
The normal way of defining methods using findBy...
method does not produce results.
Here is my parent class
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="Leave_Type",
discriminatorType=DiscriminatorType.STRING
)
public class LeaveQuota {
// the fields and the required methods
}
Here are the two child entities
@Entity
@DiscriminatorValue("Annual")
public class AnnualLeave extends LeaveQuota {
// the fields and the required methods
}
@Entity
@DiscriminatorValue("Casual")
public class CasualLeave extends LeaveQuota {
// the fields and the required methods
}
I want to query the database by filtering the Annual leaves and Casual leaves separately. Which means when I search for annual leaves, all records in the discriminator column with value "annual" should be retrieved. How can I implement this. Thanks in advance!