0

I have a class Foo with fields bar, baz, and buz and an XML mapping file:

How would I write a generic update mapper that will allow me to update records for a non-null value of one of of the fields for a given where clause?

e.g. something like

UPDATE public.foo set bar = #{bar}, baz = #{baz}, buz = #{buz}, #{item} My Mapper class looks like:
void bulkUpdate(Foo foo, @Param("userIds") Collection<Long> userIds);

But i get an error in the XMl because it doesn't look like I can pass the object and a @Param...

Any ideas?

user2395365
  • 1,991
  • 4
  • 18
  • 34
  • Short answer: Add `@Param("foo")` to the first method argument and reference its properties with `foo.` prefix i.e. `#{foo.bar}` instead of `#{bar}`. Long answer [here](https://stackoverflow.com/a/59811574/1261766). – ave Apr 20 '23 at 21:52

0 Answers0