0

I have an application in NET with iBatis and have many sql script with just one parameter. I want to expand all those with another parameter but it's almost impossible to rewrite all parameterclass. I now have this for example:

<select id="SelectAllByActionIdaction" resultMap="ResultSelectaction" parameterClass="int">
  select a.* from t_action a
  where a.actionid = #value#
</select>

This works fine, but now I want to put another variable on the query. For example like this:

  select a.* from t_actie a
  where a.actieid = #value#
  and a.editUserID = #getCurrentUserID#

The getCurrentUserID is a method which I can call everywhere in my application, how can I manage to let it work in iBatis? That wouldn't be that hard wouldn't be?

Mario
  • 582
  • 5
  • 18
  • i guess you have to create an model class to combine this two value and refer to that class in `parameterClass` – Saif Aug 12 '14 at 09:17

2 Answers2

0

I found something for you here

Passing Multiple Argument

As it says you have to create a Map object and send it to iBATIS . And in query you have to use

parameterClass="java.util.Map"

iBATIS can access the value from the map using the keys. In your case which will be like

Map<String, Object> parms = new HashMap<String, String>();
parms.put("value", "yourName");
parms.put("currentUserID", getCurrentUserID);

and

select a.* from t_actie a
where a.actieid = #value#
and a.editUserID = #currentUserID#
Community
  • 1
  • 1
Saif
  • 6,804
  • 8
  • 40
  • 61
  • like I said it is almost impossible to rewrite all parameter maps because there are to many now, this solution I allready found, but isn't the solution I'm looking for. Looked into the documentation and it looks like it's impossible to do what I want. Seems a easy function, but to hard for iBatis. – Mario Aug 12 '14 at 12:34
0

It's not possible with iBatis to do such so, it's only possible to do such with parameter mapping, but since I have to many maps allready and every query needs a modification I will look for other solutions.

Mario
  • 582
  • 5
  • 18