开发者

Hibernate ResultTransformer with JPA API

开发者 https://www.devze.com 2022-12-30 23:42 出处:网络
Has anyone figured out a smart way to do query result transformation through a similar mechanism like specifying a ResultTransformer in Hibernate?

Has anyone figured out a smart way to do query result transformation through a similar mechanism like specifying a ResultTransformer in Hibernate?

All I can think of is transforming each result row after it has been returned by the Query. Is there any other way?

For constructor projections (e.g. new DTO(arg1, arg2)) it can be defined in the JPQL query, but how about other cases?

My use case is the following :

I am worki开发者_运维问答ng on a custom Tuple projection for Querydsl, but I can't yet get it working properly with JPA. It is difficult with constructor projection, since I also need to supply the query expressions, not only the result values.

In general other use cases could also be JavaBean population (public empty construction invocation and setter-based population), using a factory method for object creation etc.


It is possible with EclipseLink JPA implementation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号