My domain class has attributes associated with an enumeration. Strange MyBatis 3.4.x (Both 3.4.0 and 3.4.4. This worked with 3.3.x) using Spring MyBatis 1.3.1 tries to match it with an unrelated enumeration and gives an error.
org.mybatis.spring.MyBatisSystemException: nested exception - org.apache.ibatis.executor.result.ResultMapException: an error occurred while trying to get the column "order_line_programmed" from the result set. Reason: java.lang.IllegalArgumentException: no enum foo.UnrelatedEnum.yes constant
My domain class is as follows:
public class OrderLine {
private Long id;
private Product product;
private ProgrammedStatus programmedStatus;
private String programmedFeedback;
private boolean completed = false;
}
ProgrammedStatus is a simple enumeration
public enum ProgrammedStatus {
yes, no, error;
}
It is this program status that is displayed in the 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>
javaType Handler, MyBatis, , .
, ,
- UnrelatedEnum Enum as ProgrammedStatus
- , UnrelatedEnum
. Handler EnumTypeHandler . , , 3.4 .