简体   繁体   English

在休眠统计中,加载和获取之间有什么区别

[英]In hibernate statistics whats the difference between load and fetch

Im mainly looking at the EntityStatics ( http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/EntityStatistics.html ).我主要看 EntityStatics ( http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/EntityStatistics.html )。 I can see a lot of fetch, loads and updates and i cant find anywhere that says what the difference between them are.我可以看到很多获取、加载和更新,但我找不到任何说明它们之间有什么区别的地方。

Working backward through the code, the fetch counter only gets incremented when the entity is retrieved from the datasource (as opposed to any caches) -通过代码向后工作,获取计数器仅在从数据源检索实体时增加(与任何缓存相反) -

    protected Object loadFromDatasource(
        final LoadEvent event,
        final EntityPersister persister,
        final EntityKey keyToLoad,
        final LoadEventListener.LoadType options) {
    final SessionImplementor source = event.getSession();
    Object entity = persister.load(
            event.getEntityId(),
            event.getInstanceToLoad(),
            event.getLockMode(),
            source
    );

    if ( event.isAssociationFetch() && source.getFactory().getStatistics().isStatisticsEnabled() ) {
        source.getFactory().getStatisticsImplementor().fetchEntity( event.getEntityClassName() );
    }

    return entity;
}

The load counter was called from too many places to track them all down, but it looks like it gets incremented any time the entity gets loaded, whether from the datasource or the caches.加载计数器从太多地方被调用以跟踪它们,但无论是从数据源还是缓存中加载实体时,它看起来都会增加。

https://vladmihalcea.com/hibernate-statistics/ This article contains explicit difference between fetch and load counts: https://vladmihalcea.com/hibernate-statistics/本文包含获取和加载计数之间的明确区别:

long getEntityLoadCount() It gives you the total number of entities that were loaded (including the one fetched from the first or second-level cache or the database) by the current EntityManagerFactory or SessionFactory. long getEntityLoadCount() 它为您提供当前 EntityManagerFactory 或 SessionFactory 加载的实体总数(包括从一级或二级缓存或数据库中获取的实体)。 long getEntityFetchCount() It gives you the total number of entities that were fetched from the database by the current EntityManagerFactory or SessionFactory. long getEntityFetchCount() 它为您提供当前 EntityManagerFactory 或 SessionFactory 从数据库中获取的实体总数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java中=和==有什么区别? - Whats the difference between = and == in java? hibernate.connection.autocommit 和 hibernate.c3p0.autocommit 有什么区别? - Whats the difference between hibernate.connection.autocommit and hibernate.c3p0.autocommit? Hibernate EAGER fetch和cascade-type all有什么区别 - What is difference between Hibernate EAGER fetch and cascade-type all 使用JPA和Hibernate时JOIN和JOIN FETCH有什么区别 - What is the difference between JOIN and JOIN FETCH when using JPA and Hibernate &lt;[]&gt; vs和之间有什么区别<null> - Whats the difference between <[]> vs <null> DelegatingFilterProxy 和 GenericFilterBean 有什么区别? - Whats the difference between DelegatingFilterProxy and GenericFilterBean? hibernate会话的get()和load()方法在获取方面有什么区别? - What is difference between get() and load() method of hibernate session with respect to fetching? 对于JPA的实体图,FETCH和LOAD有什么区别? - What is the difference between FETCH and LOAD for Entity graph of JPA? hibernate.jdbc.fetch_size 和 hibernate.jdbc.batch_size 有什么区别? - What is the difference between hibernate.jdbc.fetch_size and hibernate.jdbc.batch_size? hibernate.jdbc.fetch_size 和批量抓取策略@BatchSize 的区别 - Difference between hibernate.jdbc.fetch_size and batch fetch strategy @BatchSize
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM