Add new ConcreteProxy annotation

Description

Add a new annotation @ConcreteProxy that indicates proxies of concrete types (for inheritance models) should be created instead of the referenced type. This requires resolving the discrimination value (discriminator column or case-statement) from the database. Only valid on a root entity.

This is intended as a better replacement for the legacy (and deprecated) @Proxy annotation. For context, a user asked about this recently:

Will also include a corresponding global flag - hibernate.mapping.concrete_proxies which would effectively apply the @ConcreteProxy across each hierarchy.

Activity

Show:

Marco Belladelli December 4, 2024 at 9:50 AM

Note that we opted against adding the global configuration property hibernate.mapping.concrete_proxies, care should be exerted when enabling this feature for each entity hierarchy since retrieving the concrete type of lazy-loaded associations has a performance cost. Usage of this feature should be restricted to a limited number of types, where the “real” class of a proxy is really needed by application logic.

Alberto Michele October 2, 2024 at 3:41 PM

It looks like the issue I referenced was actually a Spring Data bug that was fixed in 2022 so the annotation is no longer needed there and I simply removed it. Sorry.

Gavin King October 2, 2024 at 11:04 AM

Why not just try it and see if it works?

Alberto Michele October 2, 2024 at 10:57 AM

Hi, I noticed today that the @Proxyannotation is deprecated.

I just want to share with you that a use case for that annotation is reported at: , so I would like to know if this new @ConcreteProxy annotation could be used in this case.

Thanks a lot.

Gavin King March 13, 2024 at 7:37 PM

That’s fine I guess. I find it an ugly word, but its the word we use so 🤷‍♂️

Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Priority

Created March 6, 2024 at 5:17 PM
Updated December 4, 2024 at 9:50 AM
Resolved April 23, 2024 at 1:37 PM