My domain class has attributes mapped to an enum. Strangely MyBatis 3.4.x (Both 3.4.0 and 3.4.4. This worked with 3.3.x) with Spring MyBatis 1.3.1 tries to map it with an unrelated enum and gives the error.
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
My domain class looks like this:
public class OrderLine {
private Long id;
private Product product;
private ProgrammedStatus programmedStatus;
private String programmedFeedback;
private boolean completed = false;
}
ProgrammedStatus is a simple enum
public enum ProgrammedStatus {
yes, no, error;
}
It is this programmedStatus which is mapped to programmed column as follows,
<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>
I even tried mapping the javaType with the typeHandler, but MyBatis seem to ignore it.
Few information which may find useful,
- UnrelatedEnum is also a simple Enum as ProgrammedStatus
- Product has an attribute which has an attribute which is of type UnrelatedEnum
I found this issue in other places of code as well. I COULD have my own specific typeHandler instead of the EnumTypeHandler here. The issue is that this enum matching is used in a lot of places in my program and migrating wit 3.4 makes my program unstable.