ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Poitras Christian <Christian.Poit...@ircm.qc.ca>
Subject RE: ProbeException: The '...' property of the java.util.HashMap class is not a List or Array
Date Wed, 10 Sep 2008 14:00:32 GMT
In ColumnPairValue, I would not use

  public boolean getIsValid() {
    return (_column != null && _operator != null && _value != null);
  }

but

  public boolean isValid() {
    return (_column != null && _operator != null && _value != null);
  }

Maybe the java bean spec allows getIsValid, especially if you use .isValid as a test, but
usually, when returning boolean, you should use is instead of get.
The statement will also differ since the test will be

          <isEqual property="filter.columnValuePairs[].valid" compareValue="true" prepend="filter.columnValuePairs[].prepend">


Try this and see if it works.

Christian

________________________________
From: Kyunam Kim [mailto:kyunam_kim@esri.com]
Sent: Tuesday, September 09, 2008 6:24 PM
To: user-java@ibatis.apache.org
Subject: RE: ProbeException: The '...' property of the java.util.HashMap class is not a List
or Array

Thanks Clinton & Sundar

Here goes full stacktrace and pojo classes.

Thanks!!!
Q


org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized
SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in com/esri/business/query/QuerySQLMap_SQL_SERVER_2008.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the query.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/esri/business/query/QuerySQLMap_SQL_SERVER_2008.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the query.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.
Caused by: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.
            at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:124)
            at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:322)
            at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
            at org.springframework.orm.ibatis.SqlMapClientTemplate.queryWithRowHandler(SqlMapClientTemplate.java:330)
            at com.esri.business.query.QueryDAO.query(QueryDAO.java:51)
            at com.esri.business.query.QueryDAOTest.testAttributeQuery1(QueryDAOTest.java:130)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:198)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:274)
            at org.springframework.test.context.junit4.SpringMethodRoadie$2.run(SpringMethodRoadie.java:207)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runBeforesThenTestThenAfters(SpringMethodRoadie.java:254)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:234)
            at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:204)
            at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:146)
            at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:151)
            at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
            at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
            at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
            at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
            at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
            at com.intellij.rt.junit4.Junit4TestMethodAdapter.run(Junit4TestMethodAdapter.java:49)
            at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/esri/business/query/QuerySQLMap_SQL_SERVER_2008.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the query.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.
Caused by: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.
            at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
            at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithRowHandler(GeneralStatement.java:133)
            at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryWithRowHandler(SqlMapExecutorDelegate.java:644)
            at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryWithRowHandler(SqlMapSessionImpl.java:121)
            at org.springframework.orm.ibatis.SqlMapClientTemplate$5.doInSqlMapClient(SqlMapClientTemplate.java:332)
            at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
            ... 27 more
Caused by: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property
of the java.util.HashMap class is not a List or Array.
            at com.ibatis.common.beans.BaseProbe.getIndexedType(BaseProbe.java:127)
            at com.ibatis.common.beans.GenericProbe.getPropertyTypeForGetter(GenericProbe.java:159)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.ConditionalTagHandler.compare(ConditionalTagHandler.java:98)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.IsEqualTagHandler.isCondition(IsEqualTagHandler.java:21)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.ConditionalTagHandler.doStartFragment(ConditionalTagHandler.java:48)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:157)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:160)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:160)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:160)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.processBodyChildren(DynamicSql.java:99)
            at com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql.process(DynamicSql.java:79)
            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)
            ... 32 more


public class QueryFilter {

  private List<ColumnValuePair> _columnValuePairs;

  public QueryFilter() {
    _columnValuePairs = new LinkedList<ColumnValuePair>();
  }

  public List<ColumnValuePair> getColumnValuePairs() {
    return _columnValuePairs;
  }

  public void setColumnValuePairs(List<ColumnValuePair> columnValuePairs) {
    _columnValuePairs = columnValuePairs;
  }
}

public class ColumnValuePair {

  private Column _column;
  private String _value;
private RangeEqualityOperator _operator = RangeEqualityOperator.EQUAL; // default
private LogicalOperator _prepend = LogicalOperator.AND; // default

  public Column getColumn() {
    return _column;
  }

  public void setColumn(Column column) {
    _column = column;
  }

  public String getValue() {
    return (_column.getIsNumeric() ? _value : StringUtils.quote(_value));
  }

  public void setValue(String value) {
    _value = value;
  }

  public RangeEqualityOperator getOperator() {
    return _operator;
  }

  public void setOperator(RangeEqualityOperator operator) {
    _operator = operator;
  }

  public LogicalOperator getPrepend() {
    return _prepend;
  }

  public void setPrepend(LogicalOperator prepend) {
    _prepend = prepend;
  }

  public boolean getIsValid() {
    return (_column != null && _operator != null && _value != null);
  }
}

public class Column {

  private int _columnId; // just index.
  private int _tableId;
  private String _columnName;
  private boolean _isNumeric;
  private boolean _isSpatial;

  public Column() {
  }

  public int getColumnId() {
    return _columnId;
  }

  public void setColumnId(int columnId) {
    _columnId = columnId;
  }

  public int getTableId() {
    return _tableId;
  }

  public void setTableId(int tableId) {
    _tableId = tableId;
  }

  public String getColumnName() {
    return _columnName;
  }

  public void setColumnName(String columnName) {
    _columnName = columnName;
  }

  public boolean getIsNumeric() {
    return _isNumeric;
  }

  public void setIsNumeric(boolean numeric) {
    _isNumeric = numeric;
  }

  public boolean getIsSpatial() {
    return _isSpatial;
  }

  public void setIsSpatial(boolean isSpatial) {
    _isSpatial = isSpatial;
  }
}


   //***************** a method in DAO   *************************
  public List query(Table table, List<Column> returnColumns, QueryFilter filter, long
userId) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("user_id", userId);
    params.put("table", table);
    params.put("return_columns", returnColumns);
    params.put("filter", filter);
    DefaultRowHandler rowHandler = new DefaultRowHandler(table, returnColumns);
    getSqlMapClientTemplate().queryWithRowHandler("query", params, rowHandler);
    return rowHandler.getRows();
  }

<select id="query" parameterClass="map" resultClass="java.util.LinkedHashMap" remapResults="true">
    SELECT TOP $table.maxResultCount$
    <isEmpty property="return_columns">
      *
    </isEmpty>
    <dynamic>
      <isPropertyAvailable property="return_columns">
        <iterate property="return_columns" conjunction=",">
          <isEqual property="return_columns[].isSpatial" compareValue="true">
            $return_columns[].columnName$.STAsBinary() AS $return_columns[].columnName$
          </isEqual>
          <isEqual property="return_columns[].isSpatial" compareValue="false">
            $return_columns[].columnName$
          </isEqual>
        </iterate>
      </isPropertyAvailable>
    </dynamic>

    FROM
    $table.tableName$

    <dynamic prepend="WHERE">
      <isPropertyAvailable property="filter" prepend="AND">
        <iterate property="filter.columnValuePairs">
          <isEqual property="filter.columnValuePairs[].isValid" compareValue="true" prepend="filter.columnValuePairs[].prepend">
            $filter.columnValuePairs[].column.columnName$ $filter.columnValuePairs[].operator$
$filter.columnValuePairs[].value$
          </isEqual>
        </iterate>
      </isPropertyAvailable>
    </dynamic>
  </select>

________________________________
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Tuesday, September 09, 2008 12:25 PM
To: user-java@ibatis.apache.org
Subject: Re: ProbeException: The '...' property of the java.util.HashMap class is not a List
or Array

Is it?  You'll need to provide a lot more information.

  * What does the class definition look like?
  * What is the full exception stack trace?

One think I'm not sure about is the syntax:

     property="filter.columnValuePairs[].isValid"

IIRC, the [] syntax is reserved for generating parameters only.  Unless someone changed it,
you need to use a fully qualified value in the dynamic SQL elements themselves.

Clinton

2008/9/9 Kyunam Kim <kyunam_kim@esri.com<mailto:kyunam_kim@esri.com>>

:)



So Clinton, any idea why a list of my pogos is being interpreted as HashMap?



Thanks,

Q

________________________________
________________________________

Subject: FW: ProbeException: The '...' property of the java.util.HashMap class is not a List
or Array
Date: Tue, 9 Sep 2008 09:54:24 -0700
From: kyunam_kim@esri.com<mailto:kyunam_kim@esri.com>

To: user-java@ibatis.apache.org<mailto:user-java@ibatis.apache.org>

Hi All,



I haven't heard any response on this post.

I would appreciate it if you could give a 2nd look...  :)



Thanks,

Q

________________________________

From: Kyunam Kim [mailto:kyunam_kim@esri.com<mailto:kyunam_kim@esri.com>]
Sent: Monday, September 08, 2008 3:00 PM
To: user-java@ibatis.apache.org<mailto:user-java@ibatis.apache.org>
Subject: ProbeException: The '...' property of the java.util.HashMap class is not a List or
Array



1) In the below, filter.columnValuePairs returns a java.util.List, but I get:

Cause: com.ibatis.common.beans.ProbeException: The 'filter.columnValuePairs' property of the
java.util.HashMap class is not a List or Array.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:



What am I doing wrong so that it thinks I passed in HashMap?



2) Can you dynamically set a value for prepend attribute? Like  prepend="filter.columnValuePairs[].prepend"
 ?



    <dynamic prepend="WHERE">

      <isPropertyAvailable property="filter" prepend="AND">

        <iterate property="filter.columnValuePairs">

          <isEqual property="filter.columnValuePairs[].isValid" compareValue="true" prepend="filter.columnValuePairs[].prepend">

            $filter.columnValuePairs[].column.columnName$ $filter.columnValuePairs[].operator$
$filter.columnValuePairs[].value$

          </isEqual>

        </iterate>

      </isPropertyAvailable>

    </dyamic>



Thanks,

Q




Mime
View raw message