[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5854?page=c...
]
Floris Kruisselbrink commented on HHH-5854:
-------------------------------------------
There seems to have been no action whatsoever on this bug, but unfortunately it is still
there and I also came across it.
I tried the test from testCase.zip and can confirm the bug is still there in hibernate
3.6.2.
To help in reproducing this problem, I have modified the testcase a little so you can just
download and run it with maven:
- used hsqldb instead of derby to work with an in-memory temporary database
- moved HibernateApp to HibernateTest, made it possible to run it as java application as
well as a junit test.
- added pom.xml to collect dependencies, run unit test, set up eclipse project etc in one
go.
Attached as hibernate-test.zip
To run the unit-test use 'mvn test', results are in target/surefire-reports
ArrayIndexOutOfBounds on fetching onetoone associations using
projections
-------------------------------------------------------------------------
Key: HHH-5854
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5854
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.6.0
Environment: Hibernate version 3.6.0
Reporter: Krishna Sundaresan
Attachments: testCase.zip
The loading of OneToOne associations using projections results in an
ArrayIndexOutOfBounds exception when the results are loaded by the CriteriaLoader.
The stacktrace is:
{code}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at
org.hibernate.loader.criteria.CriteriaLoader.getResultColumnOrRow(CriteriaLoader.java:148)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:639)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
at testbed.app.HibernateApp.main(HibernateApp.java:24)
Java Result: 1
{code}
The problem seems to be with the way the association aliases and types are used in
getResultRow. When the types are fetched, all the types that are mentioned in the
projection clause are provided whereas when the aliases to be used are fetched
SimpleProjection's getColumnCount method seems to be ignoring columns that do not span
resulting in a mis-match of array indices.
{code:title=From CriteriaLoader.getResultRow(...)}
if ( translator.hasProjection() ) {
Type[] types = translator.getProjectedTypes();
result = new Object[types.length];
String[] columnAliases = translator.getProjectedColumnAliases();
...
{code}
The attached file has a test-case that will demonstrate the problem. Tested that on
Hibernate 3.6.0 and derby. I was able to observe this in a case where the association is
mapped by a shared primary key but I guess that same should be observable even without a
shared primary key.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira