Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
List result = session.createSQLQuery( "select distinct {node.}, {areas.} from GCP_Node node join GCP_ApplicationArea areas on node.DocumentId=areas.DocumentId " + "where areas.Name like 'BS - CF%'") .addEntity("node", GCPSimpleDocumentImpl.class) .addJoin("areas", "node.ApplicationAreas") .list();
Unfortunately I get the following exception:
java.lang.ArrayIndexOutOfBoundsException: -1 at org.hibernate.loader.custom.SQLQueryParser.substituteBrackets(SQLQueryParser.java:133) at org.hibernate.loader.custom.SQLQueryParser.process(SQLQueryParser.java:85) at org.hibernate.loader.custom.SQLCustomQuery.<init>(SQLCustomQuery.java:157) at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:20) at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:113) at org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:137) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164) ...
Attachments
1
11 Oct 2006, 12:00 PM
Activity
Show:
Gus HeckJuly 24, 2009 at 6:45 PM
Ah... interestingly enough I had inadvertently made the collection with a many-to-many rather than one-to-many element... When I switched it to one-to-many, this error went away...
HTH...
Gus HeckJuly 24, 2009 at 6:07 PM
I got this stack trace also... when our spring config tried to load up hibernate with this query... if I remove the query (and the collection I am mapping to it) things are fine... (there were where clauses to filter it to open issues, but I removed them trying to get something to work, with no success).
<sql-query name="loadOpenIssues"> <load-collection alias="x" role="Shipment.openIssues"/> select {x.*} from Issue where shipmentRefNum=:shipmentReference </sql-query>
Artur JonakOctober 11, 2006 at 12:00 PM
Attached the complete IDEA project containing the test case named: test.sqlquery.SQLQueryTest which reproduces the error. In the test/conf directory thereis also schema.sql along with hibernate and connection properties in test.properties.
Have fun!
Max Rydahl AndersenOctober 11, 2006 at 11:07 AM
could you make a testcase ? I can't make it fail with the above.
I have the following mapping:
<class name="GCPSimpleDocumentImpl" table="GCP_Node" mutable="false">
<id name="DocumentId" />
...
<set name="ApplicationAreas" table="GCP_ApplicationArea" cascade="none" order-by="Name" sort="natural" mutable="false">
<key column="DocumentId"/>
<element type="string" column="Name"/>
</set>
</class>
and I try to run an SQL query:
List result = session.createSQLQuery(
"select distinct {node.}, {areas.} from GCP_Node node join GCP_ApplicationArea areas on node.DocumentId=areas.DocumentId " +
"where areas.Name like 'BS - CF%'")
.addEntity("node", GCPSimpleDocumentImpl.class)
.addJoin("areas", "node.ApplicationAreas")
.list();
Unfortunately I get the following exception:
java.lang.ArrayIndexOutOfBoundsException: -1
at org.hibernate.loader.custom.SQLQueryParser.substituteBrackets(SQLQueryParser.java:133)
at org.hibernate.loader.custom.SQLQueryParser.process(SQLQueryParser.java:85)
at org.hibernate.loader.custom.SQLCustomQuery.<init>(SQLCustomQuery.java:157)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:20)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:113)
at org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:137)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
...