我不会说话,英文写得很好。对不起。 但我需要你的帮助。 所以......尽管我的英语很糟糕......我正在写作。 如果我的英语很糟糕,请估计并理解我的问题。
我们开始吧。
<小时/>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查询xml
<select id="testSelect" parameterClass="a.d.e.TestVO" resultClass="int">
select a, b
from TEST_TBL
where 1 = 1
<isNotEmpty prepend="AND" property="productId">
product_id = #productId#
<isNotEmpty>
</select>
有时会出现以下错误:
> --- 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)...
奇怪的是,它间歇性地发生......
你有什么想法吗?任何答案或评论都会有帮助。
谢谢。
最佳答案
当您编写 #productId# 时,ibatis 会从参数类中调用此属性的 get-Method 。
你的 getter 和 setter 的方式是错误的。 getter 应该返回值,setter 应该设置值。
更改它,并告诉我们您的结果;)
示例:
CommonVO.java
public void setProductId(String productId)
{
this.productId = productId;
}
public String getProductId()
{
return this.productId;
}
关于java - Mybatis参数类有bug报告吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13817130/