[hibernate-dev] How to deal with a constant in CriteriaQuery

Steve Ebersole steve at hibernate.org
Tue Apr 24 10:29:34 EDT 2018


On Tue, Apr 24, 2018 at 8:45 AM Gail Badner <gbadner at redhat.com> wrote:

> Yes, that should work with CriteriaQuery as well. It's a reasonable
> workaround.
>
> If JPA doesn't support this now, is it something that should be supported
> in the future?


The problem with defining support for this in the spec is that it is
relying on Hibernate's "SQL function registry" and its `SQLFunction`
contract.  I seriously doubt we'd get all the EG members to agree to some
standardization of anything like a `SQLFunction` contract.

I think proposing to add additional functions to the spec as "built-in" is
probably more likely.  I can especially see EXTRACT being likely.  Maybe
DATEDIFF.  Oracle for sure does not support DATEDIFF, but it does support
the EXTRACT-from-INTERVAL approach.   Anyone know offhand other databases
which to not define DATEIDFF?

I personally think having DATEDIFF defined as "built-in" is the best option
as the provider can always map that to EXTRACT-from-INTERVAL for Oracle,
etal - its much harder to do that by mapping EXTRACT-from-INTERVAL to
DATEDIFF.


More information about the hibernate-dev mailing list