Folks,
When my DTO object that I am "Select new"'ing into has a constructor that takes native types, I get the error attached.
If my DTO has a ctor which takes wrapper types, the code works.
If it has both, then Hibernate seems to prefer the native version, and I get the error.
I tried implementing the native-type ctor in two ways, using the "this" keyword to delegate to the wrapper-type ctor or with direct calls to the setter methods on the DTO. Didn't seem to make any difference.
I'm using nightly build 20031214.
Is this worth creating a JIRA issue for?
Code:
[junit] Testcase: testFindDocumentsByCaseDTOsWithEmptyCriteria(nrm.clas.persistence.document.test.DocumentPersistenceManagerTest): Caused an ERROR
[junit] Error finding documents by case
[junit] nrm.clas.persistence.PersistenceLayerException: Error finding documents by case
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
[junit] at nrm.clas.ExceptionUtil.instantiateException(ExceptionUtil.java:89)
[junit] at nrm.clas.ExceptionUtil.createNestedException(ExceptionUtil.java:127)
[junit] at nrm.clas.ExceptionUtil.createPersistenceLayerException(ExceptionUtil.java:312)
[junit] at nrm.clas.ExceptionUtil.createPersistenceLayerException(ExceptionUtil.java:291)
[junit] at nrm.clas.persistence.document.DocumentPersistenceManagerImpl.findDocumentsByCaseDTOs(DocumentPersistenceManagerImpl.java:162)
[junit] at nrm.clas.persistence.document.test.DocumentPersistenceManagerTest.testFindDocumentsByCaseDTOsWithEmptyCriteria(DocumentPersistenceManagerTest.java:45)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at nrm.clas.test.ClasTestCase.run(ClasTestCase.java:508)
[junit] Caused by: nrm.clas.common.persistence.PersistenceException: find
[junit] at nrm.clas.persistence.BasePersistenceManagerImpl.handleError(BasePersistenceManagerImpl.java:97)
[junit] at nrm.clas.persistence.BasePersistenceManagerImpl.handleError(BasePersistenceManagerImpl.java:116)
[junit] at nrm.clas.persistence.BasePersistenceManagerImpl.find(BasePersistenceManagerImpl.java:365)
[junit] at nrm.clas.persistence.document.DocumentPersistenceManagerImpl.findDocumentsByCaseDTOs(DocumentPersistenceManagerImpl.java:159)
[junit] ... 16 more
[junit] Caused by: net.sf.hibernate.QueryException: could not instantiate: class nrm.clas.dto.document.CaseDocumentDTO
[junit] at net.sf.hibernate.hql.QueryTranslator.getResultColumnOrRow(QueryTranslator.java:993)
[junit] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:221)
[junit] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
[junit] at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
[junit] at net.sf.hibernate.loader.Loader.list(Loader.java:940)
[junit] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
[junit] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
[junit] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
[junit] at nrm.clas.persistence.BasePersistenceManagerImpl.find(BasePersistenceManagerImpl.java:359)
[junit] ... 17 more
[junit] Caused by: java.lang.NullPointerException
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
[junit] at net.sf.hibernate.hql.QueryTranslator.getResultColumnOrRow(QueryTranslator.java:990)
[junit] ... 25 more