Vlad Mihalcea (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYmVmN2M4MWIy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiYmVmN2...
) HHH-14000 (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiYmVmN2...
) Allow a custom Type that was registered via Type Contributors to be resolved by its
class, not just its name (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiYmVmN2...
)
Change By: Vlad Mihalcea (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Considering we have a custom Type we register like this:
{noformat}@Override
protected void addConfigOptions(Map options) {
options.put(
EntityManagerFactoryBuilderImpl.METADATA_BUILDER_CONTRIBUTOR,
(MetadataBuilderContributor) metadataBuilder ->
metadataBuilder.applyTypes( (typeContributions, serviceRegistry) -> {
typeContributions.contributeType( ArrayType.INSTANCE );
} ));
}{noformat}
When calling the following query:
{code:java}List<CorporateUserDTO> emails = entityManager.createNativeQuery(
"select " +
" u.userName as userName, " +
" u.emailAddresses as emailAddresses " +
"from CorporateUser u " +
"where u.userName = :name", "CorporateUserDTO" )
.setParameter( "name", "Vlad" )
.getResultList();{code}
Where the {{CorporateUserDTO}} result set mapping is mapped like this:
{code:java}@SqlResultSetMapping(
name = "CorporateUserDTO",
classes = @ConstructorResult(
targetClass = CorporateUserDTO.class,
columns = {
@ColumnResult(name = "userName"),
@ColumnResult(name = "emailAddresses", type = Array.class),
}
)
){code}
The following exception is thrown:
{noformat}javax.persistence.PersistenceException:
org.hibernate.type.SerializationException: could not deserialize
at
org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at
org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1542)
at org.hibernate.query.Query.getResultList(Query.java:165)
at
org.hibernate.test.type.contributor.ArrayTypeContributorTest.lambda$testNativeSQL$5(ArrayTypeContributorTest.java:99){noformat}
That’s because the {{Array}}property is resolved by {{SerializableType}} instead of
{{ArrayType}}.
(
https://hibernate.atlassian.net/browse/HHH-14000#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-14000#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100125- sha1:927dd36 )