如何使用 mybaits 关联将常量值传递给嵌套列

how to pass a constant value to nested column with mybaits association

如何将常量值“1111”传递给具有 mybatis 关联的嵌套列?

<association property="certificateType" column="{VALUE=CERTIFICATE_TYPE,TYPE='1111'}" select="getDict"/>

根据你的数据库,你可以使用

IFNULL(#{TYPE}, '1111') (mysql)

ISNULL(#{TYPE}, '1111')(sql 服务器)

在您的子查询 (getDict) 中。

另一个解决方案是您的父查询可以 return TYPE 作为值

例如说:

SELECT '1111' AS TYPE, .....

然后在你的专栏中你可以说

column={VALUE=CERTIFICATE_TYPE,TYPE=TYPE}

希望对您有所帮助。