0

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"/>
Paris Tao
  • 335
  • 1
  • 3
  • 11

1 Answers1

0

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.

h3adache
  • 1,296
  • 11
  • 18
  • The second solution works. Interface of "getDict" will handle different types, that's why I consider to pass variable i.o. hardcode in subquery. Anyway, thanks. – Paris Tao May 11 '16 at 00:24