如何通过mybaits关联将常量值传递给嵌套列 [英] how to pass a constant value to nested column with mybaits association

查看:381
本文介绍了如何通过mybaits关联将常量值传递给嵌套列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过mybatis关联将常量值'1111'传递给嵌套列?

how can I pass constant value '1111' to a nested column with mybatis association?

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

推荐答案

取决于您的数据库,您可以使用

Depending on what your db is, you can use

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

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

在您的子查询(getDict)中.

In your subquery (getDict).

另一种解决方案是您的父查询可以将TYPE作为值返回

Another solution is that your parent query can return TYPE as a value

例如说:

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

然后在您的专栏中您只能说

Then in your column you can just say

column={VALUE=CERTIFICATE_TYPE,TYPE=TYPE}

希望有帮助.

这篇关于如何通过mybaits关联将常量值传递给嵌套列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆