|
I have written a class called
BookExample to run a search against a HSQLDB database. The source for
this class is attached. BookExample also refers to a class called
BCriteria, which has a variable called "condition". I've provided a
getter and setter for that variable. And yet, when I try to run a
search using that class, I get an exception message saying "There is no READABLE property
named 'condition' in class 'java.util.ArrayList'". I've attached the SQLMap file
that refers to this class. Here's the stack trace I get when I try to
run my search... com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in com/jpprater/libutils/persist/PUBLIC_BKCATALOG_SqlMap.xml. --- The error occurred while preparing the mapped statement for execution. --- Check the book_selectByExample. --- Check the parameter map. --- Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'condition' in class 'java.util.ArrayList' at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:615) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95) at com.jpprater.libutils.Library.search(Library.java:48) at com.jpprater.libmgr.LibMgrMainFrame.btnSrchAdvActionPerformed(LibMgrMainFrame.java:204) at com.jpprater.libmgr.LibMgrMainFrame.access$300(LibMgrMainFrame.java:24) at com.jpprater.libmgr.LibMgrMainFrame$4.actionPerformed(LibMgrMainFrame.java:97) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) Caused by: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'condition' in class 'java.util.ArrayList' at com.ibatis.common.beans.ClassInfo.getGetter(ClassInfo.java:259) at com.ibatis.common.beans.ComplexBeanProbe.getProperty(ComplexBeanProbe.java:304) at com.ibatis.common.beans.ComplexBeanProbe.getObject(ComplexBeanProbe.java:190) at com.ibatis.common.beans.GenericProbe.getObject(GenericProbe.java:74) at com.ibatis.sqlmap.engine.mapping.sql.simple.SimpleDynamicSql.processDynamicElements(SimpleDynamicSql.java:83) at com.ibatis.sqlmap.engine.mapping.sql.simple.SimpleDynamicSql.getSql(SimpleDynamicSql.java:45) at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.process(DynamicSql.java:90) at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.getParameterMap(DynamicSql.java:61) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:156) ... 34 more Anyone have any ideas? Jon |
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" > <sqlMap namespace="PUBLIC_BKCATALOG" > <statement id="shutdown"> SHUTDOWN </statement> <resultMap id="abatorgenerated_BookResult" class="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> <result column="ID" property="id" jdbcType="INTEGER" /> <result column="ISBN" property="isbn" jdbcType="VARCHAR" /> <result column="AUTHOR" property="author" jdbcType="VARCHAR" /> <result column="TITLE" property="title" jdbcType="VARCHAR" /> <result column="ILLUSTRATOR" property="illustrator" jdbcType="VARCHAR" /> <result column="SERIES" property="series" jdbcType="VARCHAR" /> <result column="GENRE" property="genre" jdbcType="VARCHAR" /> <result column="CLASSIFICATION" property="classification" jdbcType="VARCHAR" /> <result column="AGE_LEVEL" property="ageLevel" jdbcType="VARCHAR" /> <result column="PUBLISHER" property="publisher" jdbcType="VARCHAR" /> <result column="COPYRIGHT" property="copyright" jdbcType="INTEGER" /> <result column="EDITION" property="edition" jdbcType="INTEGER" /> <result column="NO_COPIES" property="noCopies" jdbcType="INTEGER" /> <result column="AWARDS" property="awards" jdbcType="VARCHAR" /> <result column="LANGUAGE" property="language" jdbcType="VARCHAR" /> <result column="BKCONDITION" property="condition" jdbcType="VARCHAR" /> <result column="SIGNED" property="signed" jdbcType="BOOLEAN" /> <result column="ANTIQUE" property="antique" jdbcType="BOOLEAN" /> </resultMap> <select id="book_selectByPrimaryKey" resultMap="abatorgenerated_BookResult" parameterClass="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> select ID, ISBN, AUTHOR, TITLE, ILLUSTRATOR, SERIES, GENRE, CLASSIFICATION, AGE_LEVEL, PUBLISHER, COPYRIGHT, EDITION, NO_COPIES, AWARDS, LANGUAGE, BKCONDITION, SIGNED, ANTIQUE from PUBLIC.BKCATALOG where ID = #id:INTEGER# </select> <select id="book_selectByExample" resultMap="abatorgenerated_BookResult" parameterClass="com.jpprater.libutils.persist.BookExample" > select B.ID, B.ISBN, B.AUTHOR, B.TITLE, B.ILLUSTRATOR, B.SERIES, B.GENRE, B.CLASSIFICATION, B.AGE_LEVEL, B.PUBLISHER, B.COPYRIGHT, B.EDITION, B.NO_COPIES, B.AWARDS, B.LANGUAGE, B.BKCONDITION, B.SIGNED, B.ANTIQUE from PUBLIC.BKCATALOG as B <isEqual property="loaned" compareValue="true"> inner join PUBLIC.LOANS as L on L.BKID = B.ID </isEqual> <isParameterPresent > <iterate property="andedCrits" conjunction="and" prepend="where"> ( $andedCrits[].field$ $andedCrits.condition$ <!-- if a single string value is being searched --> <isNotNull property="andedCrits[].svalue"> $andedCrits[].svalue$ </isNotNull> <!-- if numerics are being searched --> <isNotNull property="andedCrits[].ivalue1"> $andedCrits[].ivalue1$ </isNotNull> <isEqual open=" " close=" " property="andedCrits[].condition" compareValue="between"> and </isEqual> <isNotNull property="andedCrits[].ivalue2"> $andedCrits.ivalue2$ </isNotNull> <!-- if a list search is being used --> <isNotNull property="andedCrits[].lvalues"> <iterate property="andedCrits[].lvalues" conjunction="," open="(" close=")"> #andedCrits[].lvalues[]# </iterate> </isNotNull> </iterate> <isNotNull property="orderBy"> order by $orderBy$ </isNotNull> </isParameterPresent> </select> <delete id="book_deleteByPrimaryKey" parameterClass="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> delete from PUBLIC.BKCATALOG where ID = #id:INTEGER# </delete> <insert id="book_insert" parameterClass="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> insert into PUBLIC.BKCATALOG (ISBN, AUTHOR, TITLE, ILLUSTRATOR, SERIES, GENRE, CLASSIFICATION, AGE_LEVEL, PUBLISHER, COPYRIGHT, EDITION, NO_COPIES, AWARDS, LANGUAGE, BKCONDITION, SIGNED, ANTIQUE) values (#isbn:VARCHAR#, #author:VARCHAR#, #title:VARCHAR#, #illustrator:VARCHAR#, #series:VARCHAR#, #genre:VARCHAR#, #classification:VARCHAR#, #ageLevel:VARCHAR#, #publisher:VARCHAR#, #copyright:INTEGER#, #edition:INTEGER#, #noCopies:INTEGER#, #awards:VARCHAR#, #language:VARCHAR#, #condition:VARCHAR#, #signed:BOOLEAN#, #antique:BOOLEAN#) <selectKey resultClass="java.lang.Integer" keyProperty="id" > CALL IDENTITY() </selectKey> </insert> <update id="book_updateByPrimaryKey" parameterClass="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> update PUBLIC.BKCATALOG set ISBN = #isbn:VARCHAR#, AUTHOR = #author:VARCHAR#, TITLE = #title:VARCHAR#, ILLUSTRATOR = #illustrator:VARCHAR#, SERIES = #series:VARCHAR#, GENRE = #genre:VARCHAR#, CLASSIFICATION = #classification:VARCHAR#, AGE_LEVEL = #ageLevel:VARCHAR#, PUBLISHER = #publisher:VARCHAR#, COPYRIGHT = #copyright:INTEGER#, EDITION = #edition:INTEGER#, NO_COPIES = #noCopies:INTEGER#, AWARDS = #awards:VARCHAR#, LANGUAGE = #language:VARCHAR#, BKCONDITION = #condition:VARCHAR#, SIGNED = #signed:BOOLEAN#, ANTIQUE = #antique:BOOLEAN# where ID = #id:INTEGER# </update> <update id="book_updateByPrimaryKeySelective" parameterClass="com.jpprater.libutils.persist.Book" > <!-- WARNING - This element is automatically generated by Abator for iBATIS, do not modify. This element was generated on Mon Jun 18 07:03:06 EDT 2007. --> update PUBLIC.BKCATALOG <dynamic prepend="set" > <isNotNull prepend="," property="isbn" > ISBN = #isbn:VARCHAR# </isNotNull> <isNotNull prepend="," property="author" > AUTHOR = #author:VARCHAR# </isNotNull> <isNotNull prepend="," property="title" > TITLE = #title:VARCHAR# </isNotNull> <isNotNull prepend="," property="illustrator" > ILLUSTRATOR = #illustrator:VARCHAR# </isNotNull> <isNotNull prepend="," property="series" > SERIES = #series:VARCHAR# </isNotNull> <isNotNull prepend="," property="genre" > GENRE = #genre:VARCHAR# </isNotNull> <isNotNull prepend="," property="classification" > CLASSIFICATION = #classification:VARCHAR# </isNotNull> <isNotNull prepend="," property="ageLevel" > AGE_LEVEL = #ageLevel:VARCHAR# </isNotNull> <isNotNull prepend="," property="publisher" > PUBLISHER = #publisher:VARCHAR# </isNotNull> <isNotNull prepend="," property="copyright" > COPYRIGHT = #copyright:INTEGER# </isNotNull> <isNotNull prepend="," property="edition" > EDITION = #edition:INTEGER# </isNotNull> <isNotNull prepend="," property="noCopies" > NO_COPIES = #noCopies:INTEGER# </isNotNull> <isNotNull prepend="," property="awards" > AWARDS = #awards:VARCHAR# </isNotNull> <isNotNull prepend="," property="language" > LANGUAGE = #language:VARCHAR# </isNotNull> <isNotNull prepend="," property="condition" > BKCONDITION = #condition:VARCHAR# </isNotNull> <isNotNull prepend="," property="signed" > SIGNED = #signed:BOOLEAN# </isNotNull> <isNotNull prepend="," property="antique" > ANTIQUE = #antique:BOOLEAN# </isNotNull> </dynamic> where ID = #id# </update> </sqlMap>
package com.jpprater.libutils.persist;
import java.util.List;
public final class BCriteria {
private String field;
private String condition;
private String svalue = null;
private Integer ivalue1 = null;
private Integer ivalue2 = null;
private List<String> lvalues = null;
public BCriteria() {
}
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public String getSvalue() {
return svalue;
}
public void setSvalue(String svalue) {
this.svalue = svalue;
}
public Integer getIvalue1() {
return ivalue1;
}
public void setIvalue1(Integer ivalue1) {
this.ivalue1 = ivalue1;
}
public Integer getIvalue2() {
return ivalue2;
}
public void setIvalue2(Integer ivalue2) {
this.ivalue2 = ivalue2;
}
public List<String> getLvalues() {
return lvalues;
}
public void setLvalues(List<String> lvalues) {
this.lvalues = lvalues;
}
}/*
* BookExample.java
*
* Created on June 24, 2007, 10:26 PM
*
* Used to generate SQL searches in iBATIS
*/
package com.jpprater.libutils.persist;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Jonathan.Prater
*/
public class BookExample {
private List<BCriteria> andedCrits;
private String orderBy;
private boolean loaned;
/** Creates a new instance of BookExample */
public BookExample() {
andedCrits = new ArrayList<BCriteria>();
}
public void addString(String field, String condition, String value) {
BCriteria toAdd = new BCriteria();
toAdd.setField(field);
toAdd.setCondition(condition);
toAdd.setSvalue(value);
andedCrits.add(toAdd);
}
public void addInt(String field, String condition, Integer val1, Integer
val2) {
BCriteria toAdd = new BCriteria();
toAdd.setField(field);
toAdd.setCondition(condition);
toAdd.setIvalue1(val1);
toAdd.setIvalue2(val2);
andedCrits.add(toAdd);
}
public void addList(String field, String condition, List<String> values) {
BCriteria toAdd = new BCriteria();
toAdd.setField(field);
toAdd.setCondition(condition);
toAdd.setLvalues(values);
andedCrits.add(toAdd);
}
public List<BCriteria> getAndedCrits() {
return andedCrits;
}
public void setAndedCrits(List<BCriteria> andedCrits) {
this.andedCrits = andedCrits;
}
public String getOrderBy() {
return orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
public boolean isLoaned() {
return loaned;
}
public void setLoaned(boolean loaned) {
this.loaned = loaned;
}
}
