[hibernate-issues] [JIRA] (HHH-14000) A "Could not locate appropriate constructor on class" is thrown when calling JPA createNativeQuery(String sqlString, String resultSetMapping)
Vlad Mihalcea (JIRA)
jira at hibernate.atlassian.net
Mon May 4 06:50:22 EDT 2020
Vlad Mihalcea ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Af5e8c0d3-3aae-4bb4-a4e1-25463d60d232 ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 ) HHH-14000 ( https://hibernate.atlassian.net/browse/HHH-14000?atlOrigin=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 ) 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=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 )
Issue Type: Bug Affects Versions: 5.4.15 Assignee: Vlad Mihalcea ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Af5e8c0d3-3aae-4bb4-a4e1-25463d60d232 ) 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%3Af5e8c0d3-3aae-4bb4-a4e1-25463d60d232 )
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=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14000#add-comment?atlOrigin=eyJpIjoiZjA2OTdkM2M3OTg5NDVhYmFjN2ZkNTI3NzQyZDY2YzQiLCJwIjoiaiJ9 )
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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100125- sha1:927dd36 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200504/a3fc8990/attachment.html
More information about the hibernate-issues
mailing list