[
https://issues.apache.org/jira/browse/METAMODEL-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15177810#comment-15177810
]
Ankit Kumar commented on METAMODEL-233:
---------------------------------------
Some more info : -
The changes to fix JIRA METAMODEL-195 bring this new issue.
In Query.java clone method we changed the cloning of SelectItems to use a new
method where we also pass the query.
for (SelectItem item : _selectClause.getItems()) {
q.select(item.clone(q));
}
On removing the "q" as the argument the issue is resolved but then some tests
fail on assertion on query outcome.
I guess the issue originates from the fact that in the Query.select(SelectItem
... items) method we do not clone the received SelectItems.
This proves when changing the select(SelectItems items) method with this
change. Original version just adds the received items to the _selectClause.
public Query select(SelectItem... items) {
SelectItem[] selectItems = new SelectItem[items.length];
for (int i = 0; i < items.length; i++) {
selectItems[i] = items[i].clone();
}
_selectClause.addItems(selectItems);
return this;
}
But with both changes the DerbyTest fails on some query assertions.
Any suggestions ?
> Compile query creation gives IndexOutOfBoundsException with v4.5.0
> ------------------------------------------------------------------
>
> Key: METAMODEL-233
> URL: https://issues.apache.org/jira/browse/METAMODEL-233
> Project: Apache MetaModel
> Issue Type: Bug
> Affects Versions: 4.5.0
> Reporter: Ankit Kumar
>
> With the upgrade to Metamodel 4.5.0 we notice existing Junits fail in compile
> query creation with IndexOutOfBoundsException during query rewriting.
> NOTE: The dao's and the Junits work with Metamodel v4.4.1.
> {code}
> Stacktrace : -
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.479 sec <<<
> FAILURE! - in com.hi.cdi.test.DbTestUtilsTest
> com.hi.cdi.test.DbTestUtilsTest Time elapsed: 0.479 sec <<< ERROR!
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'RawSourceDataDao': Injection of autowired dependencies failed;
> nested exception is org.springframework.beans.factory.BeanCreationException:
> Could not autowire field: private com.hi.cdi.datastore.SourceDataDao
> com.hi.cdi.rawdatastore.RawSourceDataDao.sourceDataDao; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'SourceDataDao': Invocation of init method failed; nested exception
> is java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
> at java.util.ArrayList.rangeCheck(ArrayList.java:653)
> at java.util.ArrayList.get(ArrayList.java:429)
> at
> org.apache.metamodel.query.AbstractQueryClause.getItem(AbstractQueryClause.java:111)
> at org.apache.metamodel.query.SelectItem.clone(SelectItem.java:602)
> at org.apache.metamodel.query.Query.clone(Query.java:606)
> at
> org.apache.metamodel.jdbc.dialects.DefaultQueryRewriter.beforeRewrite(DefaultQueryRewriter.java:62)
> at
> org.apache.metamodel.jdbc.dialects.AbstractQueryRewriter.rewriteQuery(AbstractQueryRewriter.java:74)
> at
> org.apache.metamodel.jdbc.dialects.LimitOffsetQueryRewriter.rewriteQuery(LimitOffsetQueryRewriter.java:52)
> at
> org.apache.metamodel.jdbc.JdbcCompiledQuery.<init>(JdbcCompiledQuery.java:51)
> at
> org.apache.metamodel.jdbc.JdbcDataContext.compileQuery(JdbcDataContext.java:306)
> at
> com.hi.cdi.datastore.SourceDataDao.getCompiledQueryToGetDistinctRecordTypesFromSourceData(SourceDataDao.java:1298)
> at
> com.hi.cdi.datastore.SourceDataDao.initSchemaObjects(SourceDataDao.java:131)
> at sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)