1

Springs DataClassRowMapper seems to be thread safe.

However all examples I see, are constructing new instances on every use.

It is doing reflection on construction, so there is some costs on constructing it.

Can we create singleton instances for DataClassRowMappers per type, and reuse them for every query?

Kees van Dieren
  • 1,232
  • 11
  • 15
  • 2
    Yes you could reuse them, no there is no cost in constructing them as there is no reflection at that point., there is some introspection and those results are stored in a cache, so the second time one is constructed there is no overhead. – M. Deinum Jul 23 '21 at 06:26

0 Answers0