Is there a way using JPA (hibernate) to search the table easyily by an entity object? I'm using a search formula with all the atributes of the entity object. So i creat a Searchobject which contains the values entered. The other values remain null. Is there a way to search for an object that matches all those values (but ignoring the null values) in the specific table? Or do i really make it like that:
if(object.attribute() != null){
ParameterExpression<Long> p = cb.parameter(Long.class,"attribute");
criteria.add(cb.equal(object.get("attribute"), p));
}
for every attribute and then add it later on the same way:
TypedQuery<IOrderDeliverable> q = entityManager.createQuery(query);
if(object.attribute() > 0)
q.setParameter("attribute", object.getAttribute());
I'm using an oracle DB if this matters.