Vlad Mihalcea (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjA2OTdkM2M3...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiZjA2OT...
) HHH-14000 (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiZjA2OT...
) A "Could not locate appropriate constructor on class" is thrown when calling
JPA createNativeQuery(String sqlString, String resultSetMapping) (
https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiZjA2OT...
)
Issue Type: Bug Affects Versions: 5.4.15 Assignee: Vlad Mihalcea (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-core Created: 04/May/2020 03:50 AM Fix Versions: 5.4.16 Priority:
Major Reporter: Vlad Mihalcea (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
When calling the following query:
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();
Where the emailAddresses uses a custom Typ and the result set mapping is mapped like
this:
@SqlResultSetMapping(
name = "CorporateUserDTO" ,
classes = @ConstructorResult(
targetClass = CorporateUserDTO.class,
columns = {
@ColumnResult(name = "userName" ),
@ColumnResult(name = "emailAddresses" , type = Array.class),
}
)
)
The following exception is thrown:
java.lang.IllegalArgumentException: Could not locate appropriate constructor on class :
org.hibernate.test.type.contributor.ArrayTypeContributorTest$CorporateUserDTO
at
org.hibernate.loader.custom.ConstructorResultColumnProcessor.resolveConstructor(ConstructorResultColumnProcessor.java:92)
at
org.hibernate.loader.custom.ConstructorResultColumnProcessor.performDiscovery(ConstructorResultColumnProcessor.java:45)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:494)
at org.hibernate.loader.Loader.processResultSet(Loader.java:2338)
It looks like the Constructor is resolved using the Hibernate Type instead of the actual
Java Type.
(
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 )