Hey everyone,
I'm getting an error when i call selectByPrimaryKey on my mapper. My
primary key is a UUID and i used a typeHandler to deal with it.
Here is the error i'm getting:
### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: There is no getter
for property named 'scheduleguid' in 'class java.util.UUID'
### The error may involve
com.project.mappers.ScheduleMapper.selectByPrimaryKey-Inline
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: There is
no getter for property named 'scheduleguid' in 'class java.util.UUID'
My generatorConfig that pertains looks like this:
...
<table tableName="Schedule" domainObjectName="Schedule">
<columnOverride column="ScheduleGuid" javaType="java.util.UUID"
jdbcType="OTHER"
typeHandler="com.project.typehandlers.UUIDTypeHandler"/>
</table>
...
and the generated selectByPrimaryKey part of the xml looks like this:
...
<select id="selectByPrimaryKey" parameterType="java.util.UUID"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from Schedule
where ScheduleGuid =
#{scheduleguid,jdbcType=OTHER,typeHandler=com.project.typehandlers.UUIDTypeHandler}
</select>
...
Thus, when i call ScheduleMapper.selectByPrimaryKey(UUID id), it's
rolling over saying that it can't find the scheduleguid property in
UUID...which is true. Am i doing something wrong?
Any help would be appreciated
解决办法:
Do me a favor - in your MyBatis MapperConfig.xml file, add this:
<typeHandlers>
<typeHandler handler="com.project.typehandlers.UUIDTypeHandler"
javaType="java.util.UUID" />
</typeHandlers>
Let me know if this fixes the problem. If it does, I'll know where to
work on MyBatis.