spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
753 stars 345 forks source link

When using @Query with ResultSetExtractor or RowMapper class a new instance is created on every call #1721

Closed appreciated closed 4 months ago

appreciated commented 7 months ago

When using the @Query annotation in Spring Data JDBC, like in the following code snippet:

@Query(value = "SELECT ...", resultSetExtractorClass = ...ResultSetExtractor.class)
List<SomeModel> someSpecialQuery();

It appears that a new instance of the ResultSetExtractor/ RowMapper is recreated on every call to the someSpecialQuery method.

This does not happen if the "ref" Parameter is being used.

Is this intended behaviour?

I'm using spring-boot-starter-data-jdbc:3.1.2