Delayed loading is the culprit ".
I sometimes find that the query speed is very slow. I found that I didn't enable delayed loading, causing recursive data to be loaded in.
If I add delayed loading, many pages will not be available, and code-level Recursive delayed loading data reading must be performed in the program.
The policies involved here are too troublesome.
For those with few associations and low levels, it's okay to use them. Once there are too many layers, I 'd rather give up object-oriented instead of simply using a table and an object policy, save all fields.
I would rather read other associated data. After all, there is a buffer, and the speed is not significantly affected. In addition, the performance of a single table is excellent.
There is also something about opensessioninview that can solve this problem, but in fact, it is a silly decision to solve delayed loading.
There is nothing to discuss about when the usage is small. It doesn't matter how to do it.
1. For small data volumes, I 'd rather let them load without delay so that database resources can be released as soon as possible, especially some locks.
2. For large data volumes, I think we need a special class to save the operation results so that it only returns what we need, rather than loading with any delay. For example, we only use the customer's name for an order query, and there is no need to delay loading other customer information.
Different requirements, different technologies, and ORM such as Hibernate bring us a lot of convenience, but we should never think of it as a "golden oil". In the key aspect that affects performance, don't forget our most basic database operations.