[hibernate-dev] [Search] The case against searching with Criteria + restrictions
Hardy Ferentschik
hardy at hibernate.org
Fri Mar 21 07:14:30 EDT 2014
Hi Guillaume,
nice job with this issue. I was about to comment on the pull request, but
now I do it here.
On 21 Jan 2014, at 11:10, Guillaume Smet <guillaume.smet at hibernate.org> wrote:
> So, my patch here [1] broke a test which checks that Criteria +
> restrictions mostly work - even if it's documented as not supported
> and not working.
>
> "Mostly" as in "you can't get the result size but you might get the
> results". See [2] for explanations.
>
> I spent some time yesterday contemplating this issue and, while I'm
> sorry for breaking this test, I still think we should apply my patch,
> remove this test and make this case not supported for good
I think you are right. I also would simplify the code and remove this test.
The documentation is clear about this:
"Only fetch mode can be adjusted, refrain from applying any other restriction.”
I am even wondering whether we should not go a step further and disallow
the use of Criterias altogether in FullTextSessionImpl by throwing an exception
in case of its use. We then can add an explicit method to FullTextSession which
allows just the setting of the fetch type for a given association of an entity.
Under the hood it can still use the Criteria, but it will prevent the unsupported use
of Criteria queries.
+1 for applying the patch and removing the test
and I probably would even go a step further.
—Hardy
More information about the hibernate-dev
mailing list