Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

iBAtis question  RSS feed

 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!