Reflection Error

20 views
Skip to first unread message

kweisser

unread,
Oct 16, 2012, 1:44:32 AM10/16/12
to mybati...@googlegroups.com
I'm getting error that I can't seem to understand. I'm using the mybatis 3.2
Snapshot jar.

The error is:

### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: There is no getter for
property named 'lineNo' in 'class java.lang.String'
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no
getter for property named 'lineNo' in 'class java.lang.String'

My XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
&quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;>
<mapper namespace="....data.mapperMyObjectMapper">
<resultMap id="line" type="....model.Line">
<result property="lineNo" column="LINE_NO"
typeHandler=".....data.typehandlers.LineNoTypeHandler"/>
</resultMap>

<select id="loadDetail" parameterType="String" resultMap="line"
resultType="....model.Line">
SELECT ID AS "id", LINE_NO
FROM detail
WHERE id = #{id})
FOR FETCH ONLY
</select>
...

My Line Object is as follows:

public class Line implements Serializable {

private Integer lineNo = Integer.valueOf(0);
private String id = "";

public String getId(){
return id;
}
public void setId(String id){
this.id = id;
}
public Integer getLineNo(){
return lineNo;
}
public void setLineNo(Integer lineNo) {
this.lineNo = lineNo:
}
....
}

The lineNo is a CHAR in the DB but I am using it as an Integer for various
reasons.

I assume the error would go away if I change lineNo to be String, but I as I
said there are various reasons for me not to do this. I expected it to hit
my typeHandler which would handle the String to Integer conversion, but it's
not making it that far.

Any suggestions on how to work around this?




--
View this message in context: http://mybatis-user.963551.n3.nabble.com/Reflection-Error-tp4025858.html
Sent from the mybatis-user mailing list archive at Nabble.com.

Larry Meadors

unread,
Oct 17, 2012, 11:26:32 PM10/17/12
to mybati...@googlegroups.com
That looks really overcomplicated, but change "WHERE id = #{id})" to
"WHERE id = #{value})" and it'll probably work. Can't say for sure
because you didn't send all the code. Try it first.

Larry
Reply all
Reply to author
Forward
0 new messages