Lazy delayed loading in hibernate

Source: Internet
Author: User

Hibernate is related to lazy on the parent end of one-to-one and others-to-one queries.

Hibernate3 has the lazy attribute in the association. If it is hibernate2, it should be set outer-join = "false", then the associated object, set lazy = "true" in the class place"

First, you can set lazy in the class label of the parent to-one to solve the problem. In this way, when querying the son, no extra SQL statements will be sent.

For one-to-one, in hibernate2, because one-to-one does not have the lazy option, you can only set outer-join = "false. Hibernate3 has been added to lazy, so this problem does not occur.

In general, if you find that there is excessive SQL sending when querying your son, it must be your misuse of hibernate. Practice has proved that the above solution is feasible.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.