Hibernate ResultTransformer is @Deprecated. What to use instead?

I use query.setResultTransformer(**), but this method is titled Deprecated.

Which method replaced setResultTransformer?

For the moment, there is no replacement.

In 6.0, the ResultTransformer will be replaced by a @FunctionalInterface, but the underlying mechanism of transforming the Object[] property values will probably be the same.

Therefore, you can use it as-is and, only if you upgrade to 6.0, you will have to think about replacing it with the new variant.

Hi Vlad,

Please, advice if nothing changed recently. We are using deprecated setResultTransformer now and just wondering if mechanism in new @FunctionalInterface would be the same so we can just wait or we have to think about other approach right now since we plan upgrade to Hibernate 6.0 in the future.

Thank you in advance.

Nothing has changed because the current version is 5.3.

1 Like

Could hibernate consider NOT deprecating code without offering an alternative?
My understanding of deprecating is a warning to change to a new method which would not apply here for a few reasons

  1. there is nothing to do right now to resolve the warnings apart from suppress them.
    if suppressed, when version 6 comes, it could remain deprecated and suppressed so we don’t know to migrate or the old method could be removed completely and our code is broken in which case, the deprecation didn’t help anyway.

  2. we could ignore the deprecation warnings and have to root through our code to look for valid deprecation warnings for other packages (which is kind of a waste to keep skipping by the same warnings)

  3. we could re-write our code to use a different function but that appears not to be the intention because an alternative is provided in a future version so it would likely be a waste of time.

In any case, there really is no benefit to throwing warnings up when there is no expected helpful action the end user can take.