You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "Ankit Kumar (JIRA)" <ji...@apache.org> on 2016/03/01 16:39:18 UTC

[jira] [Commented] (METAMODEL-233) Compile query creation gives IndexOutOfBoundsException with v4.5.0

    [ https://issues.apache.org/jira/browse/METAMODEL-233?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15173912#comment-15173912 ] 

Ankit Kumar commented on METAMODEL-233:
---------------------------------------

Yes this is the query which fails. What I see is that if I replace the SelectItem use instead with a Column use all over in the query then it works. Query like below instead 

Query readQuery = new Query();
            readQuery.selectDistinct()
                    .select(schemaHelper.getColumnByName(ONBOARDS_TABLE, O_RECORD_TYPE))
                    .from(schemaHelper.getFromItemByTableName(ONBOARDS_TABLE))
                    .where(schemaHelper.getColumnByName(ONBOARDS_TABLE, O_CHANGESET_ID),
                            OperatorType.EQUALS_TO, new QueryParameter())
                    .where(schemaHelper.getColumnByName(ONBOARDS_TABLE, O_DATASOURCE_NAME), OperatorType.EQUALS_TO,
                            new QueryParameter());

I suspect something is going wrong with SelectItem. We have more complex queries where changing to use SelectItem with Column all places is hard.



> 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)