Skip to main content
Bounty Awarded with 50 reputation awarded by Sarabjeet
added 463 characters in body
Source Link
Denis Tulskiy
  • 19.2k
  • 7
  • 54
  • 69

JPA provides an SqlResultSetMapping that allows you to map whatever returns from your native query into an Entity oror a custom class.

EDIT JPA 1.0 does not allow mapping to non-entity classes. Only in JPA 2.1 a customConstructorResult has been added to map return values a java class.

Also, for OP's problem with getting count it should be enough to define a result set mapping with a single ColumnResult

JPA provides an SqlResultSetMapping that allows you to map whatever returns from your native query into an Entity or a custom class.

JPA provides an SqlResultSetMapping that allows you to map whatever returns from your native query into an Entity or a custom class.

EDIT JPA 1.0 does not allow mapping to non-entity classes. Only in JPA 2.1 a ConstructorResult has been added to map return values a java class.

Also, for OP's problem with getting count it should be enough to define a result set mapping with a single ColumnResult

Source Link
Denis Tulskiy
  • 19.2k
  • 7
  • 54
  • 69

JPA provides an SqlResultSetMapping that allows you to map whatever returns from your native query into an Entity or a custom class.