0

我将二级缓存与实体管理器 Hibernate 一起使用。对于投资较少的对象 - 好的。但是如果对象有大量的其他对象的附件,日志查询Hibernate的主要本质重复了几次:

    ....from
2017-01-23 12:04:20,528 INFO  [stdout] (default task-38)         doc_contract contract0_ 
2017-01-23 12:04:20,529 INFO  [stdout] (default task-38)     inner join
2017-01-23 12:04:20,529 INFO  [stdout] (default task-38)         doc_abstract_document contract0_1_ 
2017-01-23 12:04:20,529 INFO  [stdout] (default task-38)             on contract0_.entry_id=contract0_1_.entry_id 
2017-01-23 12:04:20,529 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,543 INFO  [stdout] (default task-38)         dict_organization organizati1_ 
2017-01-23 12:04:20,543 INFO  [stdout] (default task-38)             on contract0_.org_entry_id=organizati1_.entry_id 
2017-01-23 12:04:20,543 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,543 INFO  [stdout] (default task-38)         dict_organization organizati2_ 
2017-01-23 12:04:20,544 INFO  [stdout] (default task-38)             on organizati1_.parent_id=organizati2_.entry_id 
2017-01-23 12:04:20,544 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,544 INFO  [stdout] (default task-38)         dict_contractor_account contractor3_ 
2017-01-23 12:04:20,544 INFO  [stdout] (default task-38)             on contract0_.account_entry_id=contractor3_.entry_id 
2017-01-23 12:04:20,545 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,545 INFO  [stdout] (default task-38)         dict_bank bank4_ 
2017-01-23 12:04:20,545 INFO  [stdout] (default task-38)             on contractor3_.bank_entry_id=bank4_.entry_id 
2017-01-23 12:04:20,545 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,545 INFO  [stdout] (default task-38)         dict_contractor contractor5_ 
2017-01-23 12:04:20,546 INFO  [stdout] (default task-38)             on contractor3_.contractor_entry_id=contractor5_.entry_id 
2017-01-23 12:04:20,546 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,551 INFO  [stdout] (default task-38)         dict_contractor contractor6_ 
2017-01-23 12:04:20,567 INFO  [stdout] (default task-38)             on contract0_.contractor_entry_id=contractor6_.entry_id 
2017-01-23 12:04:20,567 INFO  [stdout] (default task-38)     where
2017-01-23 12:04:20,567 INFO  [stdout] (default task-38)         contract0_.entry_id=?

.... from
2017-01-23 12:04:20,772 INFO  [stdout] (default task-38)         doc_contract contract0_ 
2017-01-23 12:04:20,772 INFO  [stdout] (default task-38)     inner join
2017-01-23 12:04:20,773 INFO  [stdout] (default task-38)         doc_abstract_document contract0_1_ 
2017-01-23 12:04:20,773 INFO  [stdout] (default task-38)             on contract0_.entry_id=contract0_1_.entry_id 
2017-01-23 12:04:20,773 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,773 INFO  [stdout] (default task-38)         dict_organization organizati1_ 
2017-01-23 12:04:20,773 INFO  [stdout] (default task-38)             on contract0_.org_entry_id=organizati1_.entry_id 
2017-01-23 12:04:20,774 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,774 INFO  [stdout] (default task-38)         dict_organization organizati2_ 
2017-01-23 12:04:20,774 INFO  [stdout] (default task-38)             on organizati1_.parent_id=organizati2_.entry_id 
2017-01-23 12:04:20,774 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,774 INFO  [stdout] (default task-38)         dict_contractor_account contractor3_ 
2017-01-23 12:04:20,780 INFO  [stdout] (default task-38)             on contract0_.account_entry_id=contractor3_.entry_id 
2017-01-23 12:04:20,780 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,780 INFO  [stdout] (default task-38)         dict_bank bank4_ 
2017-01-23 12:04:20,780 INFO  [stdout] (default task-38)             on contractor3_.bank_entry_id=bank4_.entry_id 
2017-01-23 12:04:20,781 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,781 INFO  [stdout] (default task-38)         dict_contractor contractor5_ 
2017-01-23 12:04:20,781 INFO  [stdout] (default task-38)             on contractor3_.contractor_entry_id=contractor5_.entry_id 
2017-01-23 12:04:20,781 INFO  [stdout] (default task-38)     left outer join
2017-01-23 12:04:20,788 INFO  [stdout] (default task-38)         dict_contractor contractor6_ 
2017-01-23 12:04:20,788 INFO  [stdout] (default task-38)             on contract0_.contractor_entry_id=contractor6_.entry_id 
2017-01-23 12:04:20,789 INFO  [stdout] (default task-38)     where
2017-01-23 12:04:20,789 INFO  [stdout] (default task-38)         contract0_.entry_id=?

主要实体:

    @Entity
@Table(name = "doc_contract")
@Cacheable(true)
@SequenceGenerator(name = "CUST_SEQ", sequenceName = "DOC_SEQ", allocationSize = 1)
public class Contract extends AbstractSignedDocument implements Cloneable {

持久性.xml 文件:

    <properties>
         <!-- Properties for Hibernate -->
         <property name="hibernate.hbm2ddl.auto" value="validate" />
         <property name="hibernate.show_sql" value="true" />
         <property name="hibernate.format_sql" value="true" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL9Dialect" />

         <!--Кеш второго уровня-->
          <property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory"/>
          <property name="hibernate.cache.infisnisspan.cachemanager" value="java:jboss/infinispan/container/hibernate"/>
          <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
          <property name="hibernate.cache.use_second_level_cache" value="true"/>
          <property name="hibernate.cache.use_query_cache" value="true"/>

          <property name="hibernate.ejb.interceptor.session_scoped" value="ru.fsgp.pfhdn.service.DBInterceptor"/>

          <property name="hibernate.generate_statistics" value="true"/>
          <property name="hibernate.cache.use_structured_entries" value="true"/>

      </properties>

谁能建议这可能是为什么?谢谢

4

1 回答 1

0

它帮助了 <shared-cache-mode>ALL</shared-cache-mode> 我的回答正文代码

于 2017-01-23T11:39:23.480 回答