HQL&Criteria
发布日期:2021-06-30 16:53:10 浏览次数:2 分类:技术文章

本文共 988 字,大约阅读时间需要 3 分钟。

Obviously, 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.

 

@OneToMany

@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.

转载地址:https://laurence.blog.csdn.net/article/details/5564956 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:基于Akka-Streams的HTTP代理的实现
下一篇:Hibernate的抓取策略

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月17日 13时33分00秒