Hql & criteria

Source: Internet
Author: User

Obviusly, criteria queries are more difficult to read if they get more complex-a good reason to prefer them for dynamic and programmatic query generation, but to use externalized hql and JPA Ql for predefined queries.

 

A proxy is initialized if you call any method that is not the identifier Getter
Method, a collection is initialized if you start iterating through its elements or if
You call any of the collection-management operations, such as size () and contains ().
Hibernate provides an additional setting that is mostly useful for large collections; they can be mapped as extra lazy.

 

@ Onetoworkflow
@ Org. hibernate. Annotations. lazycollection (
Org. hibernate. Annotations. lazycollectionoption. Extra
)
Private set <bid> bids = new hashset <bid> ();

 

the collection is no longer
initialized if you call size (), contains (), or isempty () -The database is queried
to retrieve the necessary information. if it's a map or a list, the Operations containskey ()
and get () also query the database directly.

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.