JPA says this is not supported. However it does not *explicitly* say it is not supported - it just "strongly implies" that it should be the column's "JDBC type" (the type of the column value in the ResultSet) in both the spec and its Javadoc.
However this is useful, for example, when you are selecting ({{@ColumnResult}}) as, e.g. a String.class, but want to use it as an argument of a {{@ConstructorResult}} which is a converted value. We could handle, e.g.:
{code} @ConstructorResult( Project.class, columns={ ..., @ColumnResult( "status", MyStatusConverter.class ) } )
enum Status { ... }
class MyStatusConverter implements AttributeConverter<Status,String> { ... }
class Project { ...
Project(..., Status status) { ...} ... }
{code}
We could also implement "easy button" support for cases where we have String or int used as the "JDBC type" as an argument that is an enum. This would leverage our {{@Enumerated}} support. |
|