我正在使用 iBATIS 调用 MSSQL Server 上的存储过程,输入参数是放入映射的 POJO 上的属性:
Map<String, Object> saveMap = new HashMap<String, Object>();
saveMap.put("obj", myArticle);
update("save", saveMap);
所有参数都正确设置为过程的输入,因此没有任何问题。但其中一个参数是输出参数,我希望将其设置回 POJO,但 iBATIS 却使用一个额外的映射 "obj.new"=false
来放置该映射。
下面是显示基本思想的映射的简化版本:
<procedure id="save">
{<include refid="Core.returned_value" />
CALL SPRC_ARTICLE_NAME_SAVE (
<include refid = "Core.common_fields" />
@pArticle_id = #obj.art_id#
, @pArtname = #obj.artname#
, @pNewArticleName_flg = #obj.new,mode=INOUT#
)}
</procedure>
调用该过程后,我在 Map 中有两个映射传递给 iBATIS:
-
"obj"=POJO
-
"obj.new"=False
现在我看到 iBatis 文档说“执行存储过程时 - iBATIS 将为 OUTPUT 参数创建对象”所以这是有道理的。但我的问题是,是否有办法指示 iBATIS 在调用过程后将布尔值放回 POJO?我宁愿不做额外的工作,从地图中获取值并将其设置为我自己的 POJO。
// 乌伦
I'm using iBATIS to call a Stored Procedure on MSSQL Server, the input parameters are properties on a POJO that is put to the map:
Map<String, Object> saveMap = new HashMap<String, Object>();
saveMap.put("obj", myArticle);
update("save", saveMap);
All parameters are set correctly as input to the procedure so nothing wrong there. But one of the parameters is a output-parameter and and I was expecting it to be set back to the POJO but instead one extra mapping "obj.new"=false
is put the map by iBATIS.
Here's a simplified version of the mapping showing the basic idea:
<procedure id="save">
{<include refid="Core.returned_value" />
CALL SPRC_ARTICLE_NAME_SAVE (
<include refid = "Core.common_fields" />
@pArticle_id = #obj.art_id#
, @pArtname = #obj.artname#
, @pNewArticleName_flg = #obj.new,mode=INOUT#
)}
</procedure>
After calling the procedure I have two mappings in Map passed to iBATIS:
"obj"=POJO
"obj.new"=False
Now I see that iBatis documentation saids "When executing stored procedures – iBATIS will create objects for OUTPUT parameters" so it makes sense. But my question is if there a way to instruct iBATIS put back the boolean value to the POJO after the procedure is called? I rather don't do the extra work of getting the value out of the map and set it to the POJO my self.
// Uhlén
发布评论
评论(1)
您可以使用显式参数映射。请参阅手册第 21 页
它相当冗长,但它过去为我工作过。
You can using an explicit parameter map. See Page 21 of the manual
Its rather verbose but its worked for me in the past.