The most common, probably, is the n + 1 select problem, when lazy loading of the collection causes the database to be hit with n + 1 separate queries instead of a single connection request.
Common sense is the antidote to such questions :-) I believe that all relevant sources (primarily the Hibernate reference ) discuss in detail (and other related) issues along with permissions and workarounds. In short, you should not blindly copy recipes from a cookbook - measure the performance of your code and tune it accordingly. If you see too many releases, you can selectively switch from lazy loading to join or to query the retrieval strategy for this particular property / class / request. (Note that both have their own potential flaws, so again, measuring performance is key.)
Another problem occurs when the client code depends on the actual type of the object / property (for example, by testing it with instanceof . Such code is interrupted if it encounters a proxy object that is not an instance of the specific class that it denotes. However, this does not The best idea is to write such code anyway, and it is very rarely necessary, but sometimes it is inherited by legacy code, which causes a conflict that can make it difficult to work around.
source share