org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘order_line_programmed’ from result set. Cause: java.lang.IllegalArgumentException: No enum constant foo.UnrelatedEnum.yes
我的域类看起来像这样:
public class OrderLine { private Long id; private Product product; private ProgrammedStatus programmedStatus; private String programmedFeedback; private boolean completed = false; }
ProgrammedStatus是一个简单的枚举
public enum ProgrammedStatus { yes, no, error; }
正是这个编程的状态映射到编程列,如下所示,
<resultMap id="orderLineResult" type="foo.OrderLine"> <id property="id" column="technical_order_line_id" /> <result property="programmedStatus" column="order_line_programmed" typeHandler="org.apache.ibatis.type.EnumTypeHandler" /> <result property="programmedFeedback" column="order_line_programmed_feedback" /> <result property="completed" column="order_line_completed" javaType="java.lang.Boolean" typeHandler="org.apache.ibatis.type.BooleanTypeHandler" /> <association property="product" notNullColumn="order_line_product_id" resultMap="foo.repository.mapper.ProductMapper.productResult" /> </resultMap>
我甚至尝试使用typeHandler映射javaType,但MyBatis似乎忽略了它.
很少有可能有用的信息,
> UnrelatedEnum也是一个简单的Enum as ProgrammedStatus
> Product有一个属性,其属性类型为UnrelatedEnum我在其他代码处也发现了这个问题.我可以在这里使用我自己的特定typeHandler而不是EnumTypeHandler.问题是这个枚举匹配在我的程序中的很多地方使用,并且迁移机智3.4使我的程序不稳定.
删除明确提到的枚举typeHandler对我有用Remove : typeHandler=”org.apache.ibatis.type.EnumTypeHandler”
<resultMap id="orderLineResult" type="foo.OrderLine"> <id property="id" column="technical_order_line_id" /> <result property="programmedStatus" column="order_line_programmed" /> <result property="programmedFeedback" column="order_line_programmed_feedback" /> <result property="completed" column="order_line_completed" javaType="java.lang.Boolean" typeHandler="org.apache.ibatis.type.BooleanTypeHandler" /> <association property="product" notNullColumn="order_line_product_id" resultMap="foo.repository.mapper.ProductMapper.productResult" /> </resultMap>
精彩评论