About the @Proxy annotation. We’re using extensively in our application (300+ entities has it) For all these cases, I believe 100% of them we’re using as @Proxy(lazy=false) to annotate an entity in an entity hierarchy using single table and column discriminators. Without the annotation, it’s very common that hibernate loads a proxy, instead of the real entity class which very often leads to some ClassCastException in several places. The https://hibernate.atlassian.net/browse/HHH-16254 is one example that hibernate behaves differently from the hibernate 5.x series. An proxy is returned if I’m using cache, fetch mode select and batch fetch. If I change one of these parameters, like drop the cache, or disable batch fetch, hibernate will not return me a proxy, but the real entity. For our use cases, what’s important is to have a way to configure our mappings that a proxy won’t be returned, but the real class. I’m very interested in discuss this further and provide more info if needed in order to see how this situation is best solved. |