I'm having two DAO classes FeeGroup
and FeeHeading
like this
class FeeGroup {
private int id;
private String name;
private Set<FeeHeading> feeHeadings;
private booelan isActive;
//getters & setters
}
class FeeHeading {
private int id;
private String name;
private FeeGroup feeGroup;
private booelan isActive;
//getters & setters
}
This is the HQL
query to fetch results based on isActive
values of both FeeHeading
and FeeGroup
.
select fg.feeHeadings
from FeeHeading fh
join fh.feeGroup fg
where fg.isActive = 1
and fg.isOptional = 0
and fh.isActive = 1
and fg.id = 78
The FeeGroup
with id 78 is having 10 FeeHeading
s under it and only one heading is having isActive as 1. The current query is returning 10 records even if I have given the filter condition as fh.isActive = 1
. But when I change my query to
select fh.name
from FeeHeading fh
join fh.feeGroup fg
where fg.isActive = 1
and fg.isOptional = 0
and fh.isActive = 1
and fg.id = 78
Only one record is coming which is the only active record. So why I'm not getting a filtered Set
in the first place even if the condition is given or what should I do in the query to get it filtered?