0

I have a situation where I am making a read request to a database with a long, complex query that needs to map to a complex object. Based on my research, it looks like I want to use @SqlResultSetMapping to handle the mapping, but I would like to put my query into the jpa-named-queries.properties file because it is so long. I can only find examples of @SqlResultSetMapping with @NamedNativeQuery that shows the query passed into the query parameter of the annotation as a string. Is it possible to use @SqlResultSetMapping with an externalized query, and if so, can anyone provide and example of how to do this? Thanks!

  • SqlResultSetMapping is used for mapping an sql _result_ set... that is a jdbc ResultSet not the result of a jpa query. – Michael Wiles Jun 24 '22 at 13:51
  • Hi @michael-wiles. Thanks for the reply. I might have some of my terminology wrong. Basically, [this is the sort of think I am trying to acheive](https://github.com/eugenp/tutorials/blob/master/persistence-modules/java-jpa/src/main/java/com/baeldung/jpa/sqlresultsetmapping/Employee.java). But I'd like that query in the NamedQuery annotation to be externalized. Currently I have it in a properties file, and if I have a repository method named the same as the query, it picks it up. But I can't handle the mapping that way. – Nathan Coates Jun 24 '22 at 14:05

0 Answers0