1

I don't speak, write english well. sorry. But I need your help. so... despite crummy my english.. I'm wrting. If I do crummy enlish, please estimate and understand my question.

here we go.


CommonVO.java

 package a.b.c;

 public class CommonVO {

     private  String productId;

     public void setProductId(String productId)
     {
         return this.productId;
     }

     public String getProductId(String productId)
     {
         this.productId = productId;
     } 

TestVO.java

package a.d.e;

public class TestVO extends CommonVO {
     private  String year;

     public void setYear(String year)
     {
         return this.year;
     }

     public String getYear(String year)
     {
         this.year = year;
     }
}

Ibatis query xml

<select id="testSelect" parameterClass="a.d.e.TestVO" resultClass="int">
    select a, b
      from TEST_TBL
     where 1 = 1
     &lt;isNotEmpty prepend="AND" property="productId">
         product_id = #productId#
     &lt;isNotEmpty>
</select>

Sometimes, the following error occurs:

> --- The error occurred while applying a parameter map.
> --- Check the testSelect-InlineParameterMap.
> --- Check the parameter mapping for the 'productId' property.
> --- Cause: java.sql.SQLException: ▒▒▒▒▒▒▒▒ ▒▒ ▒ε▒▒▒ com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred while applying a parameter map.
> --- Check the testSelect-InlineParameterMap.
> --- Check the parameter mapping for the 'productId' property.
> --- Cause: java.sql.SQLException: ▒▒▒▒▒▒▒▒ ▒▒ ▒ε▒▒▒
>         at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
>         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 org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:298)
>         at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:166)
>         at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
>         at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
>         at egovframework.rte.psl.dataaccess.UmmAbstractDAO.list(UmmAbstractDAO.java:124)
>         at go.narastat.meta.std.service.impl.testSelect(StdMetaDAO.java:185)
>         at go.narastat.meta.std.service.impl.StdMetaImpl.stdMetaNoMatchSvyItemList(StdMetaImpl.java:164)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:600)...

Strangely, it occurs intermittently...

Do you have any idea? Any answer or comment will be helpful.

Thank you.

4

1 回答 1

1

当您编写 #productId# 时,ibatis 从 parameter-class 调用该属性的 get-Method 。

你的吸气剂和二传手是错误的方式。getter 应该返回值,而 setter 应该设置值。

改变它,告诉我们你的结果;)

例子:

CommonVO.java

public void setProductId(String productId)
 {
      this.productId = productId;
 }

 public String getProductId()
 {

     return this.productId;
 } 
于 2012-12-12T12:45:21.267 回答