Hello!
I have this Criteria with conjunction:
Code:
public List<House> busca(House house, BigDecimal valueMin, BigDecimal valueMax) {
Criteria crit = session.createCriteria(House.class)
.createAlias("address", "a");
Criterion val = Restrictions.between("value", valueMin, valueMax);
Criterion room = Restrictions.eq("room", house.getRoom());
Criterion dist = Restrictions.ilike("a.district", house.getAddress().getDistrict(), MatchMode.ANYWHERE);
Criterion city = Restrictions.ilike("a.city", house.getAdreess().getCity(), MatchMode.ANYWHERE);
Criterion stat = Restrictions.ilike("a.state", house.getAddress().getState(), MatchMode.ANYWHERE);
Conjunction conjunction = Restrictions.conjunction();
if (house.getRoom() != null && !house.getRoom().equals(null))
conjunction.add(room);
if (house.getAddress().getDistrict() != null && !house.getAddress().getDistrict().isEmpty())
conjunction.add(dist);
if (house.getAdreess().getCity() != null && !
house.getAdreess().getCity().isEmpty));
conjunction.add(city);
if (house.getAddress().getState() != null && !house.getAddress().getState().isEmpty()));
conjunction.add(stat);
if (valueMin != null && valueMax != null)
conjunction.add(val);
crit.add(conjunction);
return crit.list();
}
The problem is that the house registered is not returning with arguments city "Rio de Janeiro" and state "RJ".
Stacktrace is correct:
Code:
15:58:15,876 DEBUG [OgnlParametersProvider] Applying house.address.city with [Rio de Janeiro ]
15:58:15,877 DEBUG [OgnlParametersProvider] Applying house.address.state with [RJ]
Can anyone help?