在 iBatis resultMap 中返回常量
我设置了一个 resultMap,其中包含许多结果元素。我希望能够设置一个常量作为结果之一。因此,
<result property="name" column="Name"/>
我希望能够确保该名称将作为字符串“Joe”返回。在理想的情况下,我会更改查询以返回此常量,但不幸的是,这对我来说不是一个选择。我扫描了 iBatis dtd,但无法找到合适的属性。我知道我可以迭代从 iBatis 返回的列表,但我更希望能够在 iBatis 映射中执行此操作。谢谢
I have a resultMap set up with a number of result elements in it. I would like to be able to set a constant as one of the results. So instead of
<result property="name" column="Name"/>
I'd like to be able to make sure that name would come back as the string 'Joe'. In an ideal world I'd have the query changed to return this constant but unfortunately that's not an option for me. I've scanned over the iBatis dtd and was unable to find a suitable attribute. I know I could just iterate over the list returned from iBatis but i'd prefer to be able to do it in the iBatis map. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
YesNoTypeHandler.java 与 Mybatis 3 兼容:
ABC-sqlmaps.xml
ibatis.xml
YesNoTypeHandler.java compatible with Mybatis 3 :
ABC-sqlmaps.xml
ibatis.xml
如果无法更改 sql,则尝试更改映射对象的 Setter 方法。
If changing sql is not an option, then try to change Setter method for mapped object.
在我们的项目中,我们使用以下解决方案来处理过程 DB 值,例如布尔值。
ABC-sqlmaps.xml
ibatis.xml
YesNoTypeHandler.java
也许使用相同的配置您就能定义一个常量。
In our project we use the solution below for process DB values, e.g. Boolean values.
ABC-sqlmaps.xml
ibatis.xml
YesNoTypeHandler.java
May be using the same configuration you will be able to define a constants.