can we assign a string to a column directly in the resultMap association?

8 views
Skip to first unread message

w agamem

unread,
Oct 26, 2019, 4:11:42 AM10/26/19
to mybatis-user
like this:
<association property="favorite" column="{vehicleType='car'}" select="queryVehicle"/>

the 'car' is a string, and i get error:
org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'car' from result set.

is there some way to assign a string to the column directly?

Guy Rouillier

unread,
Oct 27, 2019, 12:04:57 AM10/27/19
to mybatis-user
You can assign a constant value to a result in your SQL statement:

    select make, model, 'car' as vehicleType
    from auto_products
    ...

You can't do an assignment in the column attribute as you show below.  That attribute needs to refer to a column name.

--
Guy Rouillier
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/38bf1af5-cd61-49fb-afc5-3e1e45af4b81%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages