users@jpa-spec.java.net

[jpa-spec users] Specify that AttributeConverter's must work on native queries

From: Guillermo González de Agüero <z06.guillermo_at_gmail.com>
Date: Thu, 04 May 2017 12:01:08 +0000

Hi,

AttributeConverter's are one of my favourite JPA 2.1 features, but
unfortunately, the spec only mandates them to work on JPQL queries and
Criteria queries. Its behaviour on native queries is unspecified (point 3.9
of the spec):

*"[...] The persistence provider must apply any conversion methods to
instances of attribute values in path expressions used within Java
Persistence query language queries or criteria queries (such as in
comparisons, bulk updates, etc.) before sending them to the database for
the query execution. [...] If the result of a Java Persistence query
language query or criteria query includes one or more entity attributes for
which conversion mappings have been specified, the persistence provider
must apply the specified conversions to the corresponding values in the
query result before returning them to the application. [...]"*

As a user, I expect them to also work on native queries, and EclipseLink
already does that. However, it doesn't work on Hibernate, and the spec
doesn't force it to work. This drastically reduces the possibilities of
this feature, as they can only be used on entities where no native queries
are involved.

I propose to rephrase point 3.9 in order to account for native queries in
addition to JPQL and Criteria ones. Was it an intended omission on 2.1 or
did it just wend unnoticed?


Regards,

Guillermo González de Agüero.