This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iBAtis question

 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

I have a list of School objects which I'm passing to a query. The OpenSchool object has two properties, school and district. I'm sort of new to iBatis so I may be missing something here but I have the following query:

<select id="getSchoolData" parameterClass="list" resultClass="OpenSchool">
SELECT schoolID, districtName FROM organizations
<dynamic prepend=" where school in ">
<iterate open=" (" close=") " conjunction=",">
#school[]#
</iterate>
</dynamic>
AND district= #district#
</select>

The value of district in the entire list is always the same, say 'ABC'. I want the query to just take one of the district values in the list but include an IN clause with all the schools. I'm not telling iBatis the right thing, obviously (see below). I don't see any dynamic SQL technique to solve this. What is the best solution?


com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in xxx/xxx/xxx/xxx/xxx/xxxx/xxx/District.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the District.getSchoolData.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: Error getting ordinal list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:204)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:94)
Caused by:
com.ibatis.common.beans.ProbeException: Error getting ordinal list from JavaBean. Cause java.lang.StringIndexOutOfBoundsException
at com.ibatis.common.beans.BaseProbe.getIndexedProperty(BaseProbe.java:86)
at com.ibatis.common.beans.GenericProbe.getObject(GenericProbe.java:54)
at com.ibatis.sqlmap.engine.exchange.ListDataExchange.getData(ListDataExchange.java:63)
at com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap.getParameterObjectValues(ParameterMap.java:133)
at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:181)
... 11 more
Caused by:
java.lang.StringIndexOutOfBoundsException
at java.lang.String.substring(String.java:1092)
at com.ibatis.common.beans.BaseProbe.getIndexedProperty(BaseProbe.java:50)
... 15 more


Thanks
Eric
 
John Eric Hamacher
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the answer . . . use a Map with school having an Arralist and district having a single value.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic