how to add custom property to resultMap' result tag?

80 views
Skip to first unread message

Lianghua Yu

unread,
Feb 28, 2020, 10:48:44 PM2/28/20
to mybatis-user
resultMap' result tag have `property/column/javaType/jdbcType/typeHandler`  properties,now I want to add `remark` property in to result tag, and how to  parse it in java code? like this:

```
<resultMap id="authorResult" type="Author">
  <id property="id" column="author_id" remark="userId"/>
  <result property="username" column="author_username" remark="userLoginName"/>
  <result property="password" column="author_password" remark="userLoginPwd"/>
  <result property="email" column="author_email" remark="userEmail"/>
</resultMap>
```

Iwao AVE!

unread,
Mar 1, 2020, 5:45:34 AM3/1/20
to mybatis-user
Hello,

Parsing result map is an internal process and it is not possible to add custom attribute.
What are you trying to achieve by adding 'remark'?

Regards,
Iwao

--
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/1c2ef934-3e20-497c-b41f-2a3b9672eeae%40googlegroups.com.

Lianghua Yu

unread,
Mar 1, 2020, 5:55:57 AM3/1/20
to mybatis-user
Thanks for you reply, I want to add a describe attribute for column. 


在 2020年3月1日星期日 UTC+8下午6:45:34,Iwao AVE!写道:
Hello,

Parsing result map is an internal process and it is not possible to add custom attribute.
What are you trying to achieve by adding 'remark'?

Regards,
Iwao

On Sat, Feb 29, 2020 at 12:48 PM Lianghua Yu <aaq...@gmail.com> wrote:
resultMap' result tag have `property/column/javaType/jdbcType/typeHandler`  properties,now I want to add `remark` property in to result tag, and how to  parse it in java code? like this:

```
<resultMap id="authorResult" type="Author">
  <id property="id" column="author_id" remark="userId"/>
  <result property="username" column="author_username" remark="userLoginName"/>
  <result property="password" column="author_password" remark="userLoginPwd"/>
  <result property="email" column="author_email" remark="userEmail"/>
</resultMap>
```

--
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 mybati...@googlegroups.com.

Iwao AVE!

unread,
Mar 1, 2020, 9:16:08 AM3/1/20
to mybatis-user
I'm sorry, but I am not sure what you mean by 'add describe attribute for column'.
Please post some concrete example (code, SQL, etc.).

Regards,
Iwao

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/02eba3b2-cb71-445f-9362-a004409fe61d%40googlegroups.com.

Guy Rouillier

unread,
Mar 2, 2020, 12:28:53 AM3/2/20
to mybati...@googlegroups.com
Iwao, I'm guessing Lianghua is referring to a "remarks" column in the catalog table describing columns.  For example, MySQL has INFORMATION_SCHEMA.COLUMNS.column_comment, while DB2 has SYSIBM.SYSCOLUMNS.remarks.  If my guess is correct, Lianghua will not be able to use this in any way he seems to desire.  Foremost, system catalog tables are not updateable.  Secondly, INFORMATION_SCHEMA is not uniformly implemented across vendors.  For example, PostgreSQL does not have a remarks column in their INFORMATION_SCHEMA.  

Lianghua, do you want to persist these remarks into the database, or just use them during the execution of your program?  Either way, I think this is something you are going to have to address on your own.  As Iwao said in an earlier reply, processing of a resultMap is an internal process.

--
Guy Rouillier
Reply all
Reply to author
Forward
0 new messages