【问题标题】:Hibernate - How to retrieve a list of all entity classes which have been configured for L2 CachingHibernate - 如何检索已为 L2 缓存配置的所有实体类的列表
【发布时间】:2013-12-24 08:07:38
【问题描述】:

我想知道如何检索已配置为在 Hibernate 中进行 L2 缓存的所有实体类的列表。

如果我可以从 SessionFactory 类 (http://docs.jboss.org/hibernate/orm/3.5/javadocs/org/hibernate/SessionFactory.html) 中检索它会更好。

【问题讨论】:

    标签: java spring hibernate caching ehcache


    【解决方案1】:
    for ( EntityPersister persister : ( (SessionFactoryImplementor) sessionFactory ).getEntityPersisters().values() ) {
        if ( persister.hasCache() ) {
            // do stuff
        }
    }
    

    【讨论】:

    • 太棒了!非常感谢史蒂夫。这对这个 Hibernate 菜鸟非常有帮助。
    猜你喜欢
    • 2016-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-29
    • 2017-05-12
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    相关资源
    最近更新 更多