2

Is there any way to define a SqlResultSetMapping for use in EntityManager.createNativeQuery() without using the @SqlResultSetMapping annotation on an existing @Entity? The reason I'd like to do this is that I have a rather complicated SQL query that involves a CONNECT BY clause that is returning data that shouldn't be directly related to a specific @Entity. I'm using the SqlResultSetMapping to map the results of the query to a non-Entity POJO. It doesn't make sense to me that I need to associate my SqlResultSetMapping to an @Entity that may or may not have something to do with the results coming back. In my case, I'm putting this annotation on the closest entity but it still doesn't feel right.

Chris Williams
  • 11,647
  • 15
  • 60
  • 97
  • Maybe you can define it in an xml file? Something like orm.xml? Look into this question and answers...http://stackoverflow.com/questions/2373369/define-named-query-in-orm-xml-with-jpa-and-hibernate – Mechkov Nov 10 '16 at 21:24

0 Answers0