Hibernate, left JOIN, inner join, and left JOIN fetch difference (GO)

Source: Internet
Author: User
Tags: hibernate hql inner join left right Category: SQL Original address: Http://m33707.iteye.com/blog/829725Select from <要查询的字段> [Outer] The join on the left join returns all rows in "left_table" although there is no matching data in "right_table". Right join returns all rows in "right_table" although there is no matching data in "left_table". The result set returned by the INNER join is all matching data in two tables. Fetch: When we query the parent object, the default is only the contents of the parent, does not contain childs information, if the Parent.hbm.xml set lazy= "false" in the same time to remove all the associated childs content. The problem is that I want to hibernate both the default performance and the temporary flexibility. This is the function of fetch. We can compare the relationship between fetch and lazy= "true" to the programmatic transaction and declarative transaction in the transaction, but that is probably the meaning. Query q = Session.createquery ("From parent as parent" + "LEFT OUTER join fetch Parent.childs" + "where parent.id =: id"); In short, fetch is at the level of code to give you an initiative to seize the opportunity. You can get rid of the fetch by lazy= "true", and it will be reported as abnormal. Of course, if lazy= "false", you don't need a fetch.

Hibernate, left JOIN, inner join, and left JOIN fetch difference (GO)

  

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.