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

≡放荡痞女 提交于 2019-12-25 07:05:01

问题


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"/>

回答1:


Depending on what your db is, you can use

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

ISNULL(#{TYPE}, '1111') (sql server)

In your subquery (getDict).

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

For example by saying:

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

Then in your column you can just say

column={VALUE=CERTIFICATE_TYPE,TYPE=TYPE}

Hope that helps.



来源:https://stackoverflow.com/questions/36230661/how-to-pass-a-constant-value-to-nested-column-with-mybaits-association

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!