Java – mybatis maps attributes to wrong enumerations

My domain class has properties that map to enumerations Strangely, mybatis 3.4 X (3.4.0 and 3.4.4. This applies to 3.3. X), spring mybatis 1.3 1 attempts to map it with an unrelated enum and gives an error

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 enumeration

public enum ProgrammedStatus {
    yes,no,error;
}

It is this programming state that maps to the programming column, as shown below,

<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 to map Java types using typehandler, but mybatis seems to ignore it

There is little information that may be useful,

>Irrelatedenum is also a simple enum. As programmedstatus > product has an attribute, and its attribute type is irrelatedenum

I also found this problem in other code I can use my own specific typehandler here instead of enumtypehandler The problem is that this enumeration match is used in many places in my program, and migration wit 3.4 makes my program unstable

Solution

It's useful for me to remove the explicitly mentioned enumeration typehandler

<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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>