I like using
Hibernate for regular simple
However, I am trying to understand why anyone would resort to its
Criteria framework to assemble complex recordset criteria as opposed to simply creating a view at the database level.
E.g. here is a paraphrased snippet I am working with:
Criteria tableCriteria = session .createCriteria(SomeEntity.class) .add(Restrictions.eq("someID", someID)) .add(Restrictions.gtProperty("scoreOne", "scoreTwo")) .add(Restrictions.gt("scoreThree", scoreThreeMin)) .add(Restrictions.or(Restrictions.eq("inactive", Boolean.FALSE), Restrictions.isNull("inactive"))).addOrder(Order.asc("ordCol"))
From the naked eye perspective, it is possible but let legible to discern what this filter definition is stipulating than to simply make a DB view where these restrictions could be expressed in the form of simpler
Am I missing something? Is there an advantage to using Criteria vs. DB views that I am not aware of? Using views seems much cleaner. Is there a performance upside to Criteria?