API for creating SqlResultSetMappings #3879
Replies: 3 comments 8 replies
-
https://trello.com/c/KVV4Smqo/142-sql-resultset-mapping-builder I'm not sure though in retrospect whether allowing all types of results make sense there. |
Beta Was this translation helpful? Give feedback.
-
trello.com/c/KVV4Smqo/142-sql-resultset-mapping-builder gives me a 404 ? To be clear what I'm after is in the end not just raw classes, but mechanism to return records, map or even a json with just minimal code. in majority of cases where you are not after managed entities resultsetTransfomers worked great. This even makes sense on hql queries. |
Beta Was this translation helpful? Give feedback.
-
Allow programmatic definition of ResultSet mapping for use with native and procedure queries. E.g.:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@maxandersen and apparently others are complaining that
ResultTransformer
has been deprecated with no current replacement. I tried telling him thatgetResultList().stream().map()
is the replacement but I seem to have lost that argument.The use case is native queries where I don't want to return or have to declare an
@Entity
class, and just want to package the columns up into attributes of a class.So what I think we could do, that would avoid the need to introduce a whole new conceptual "construct" would be to provide a nice API for creating
SqlResultSetMapping
s in code. Currently they can only be defined by the annotation, which I can imagine is often inconvenient, but they already let you declare aConstructorResult
which is the thing you need in Max's use case.As an additional nice feature, I think it would also be fairly straightforward to let you define
EmbeddableResult
s for the case where you do want to map properties, but don't have something that's truly an entity. That's not supported by the JPA annotation, but I think we could support it in Hibernate.So the code would be something like, well, I dunno:
But of course more complicated things would be possible, essentially anything that's possible via
@SqlResultSetMapping
today.A slightly more complicated example:
Beta Was this translation helpful? Give feedback.
All reactions