[hibernate-dev] [Search] The case against searching with Criteria + restrictions

Hardy Ferentschik hardy at hibernate.org
Fri Mar 21 08:58:36 EDT 2014


On 21 Jan 2014, at 13:41, Sanne Grinovero <sanne at hibernate.org> wrote:

> The question of being able to filter via Criteria or Hibernate Session
> Filters is a recurring feature request so we need to be cautious here.

The question is can we support it properly (most notably correctly).

> You make good points, and if it comes to a choice of support either/or
> we'll certainly drop the Criteria filtering as obviously we won't make
> concessions on correctness.
> 
> I'm sure that Criteria filtering is actually being used by several
> other teams, and while they are aware of it being "borderline", it's
> good enough for them; so rather than drop it I want to have a better
> look at alternatives; worst case I'll end up with a refreshed
> understanding of this code area.

sure, another look cannot hurt. 

> Ultimately if we decide to drop it altogether, we might want to remove
> the option of specifying the Criteria altogether in favor or a "fetch
> graph" hint from JPA 2.1: probably more suited for the purpose and
> gives no room for unpredictable behaviour.

Good idea. Maybe I was too extreme with suggesting to throw an exception 
when using Criteria, but adding a decocted and predictable way for specifying 
fetch behaviour seems like the way forward. If nothing else we can then remove 
the mention of Criteria from the documentation in favour of the new dedicated API.
If then someone wants to use Criteria he really does it on its on risk.

—Hardy




More information about the hibernate-dev mailing list