无法删除Hibernate二级缓存?

我们在GlassFish中运行了一个用Java编写的Web应用程序,该应用程序将EhCache用作第二级缓存机制。我们确定流量不保证二级缓存,并已选择将其删除。但是,显然这比最初的想象要简单。

我将persistence.xml更改为包括... <property name="hibernate.cache.use_second_level_cache" value="false"/>,并从我们的Maven POM中删除了ehcache。

通过... EntityManagerFactory emf = Persistence.createEntityManagerFactory("devDB");对其进行读取和初始化。

完整的persistence.xml ...

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="devDB" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>jdbc/nepedia</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <shared-cache-mode>ALL</shared-cache-mode>
        <properties>
            <property name="hibernate.ejb.entitymanager_factory_name" value="devDB"/>
            <property name="hibernate.connection.release_mode" value="auto" />
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
            <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionmanagerLookup"/>
            <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
            <property name="hibernate.current_session_context_class" value="jta"/>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />
            <property name="hibernate.use_sql_comments" value="false" />
            <property name="hibernate.cache.use_second_level_cache" value="false"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.generate_statistics" value="true"/>
            <property name="hibernate.cache.use_structured_queries" value="false"/>
            <property name="hibernate.cache.use_minimal_puts" value="false"/>
            <property name="hibernate.max_fetch_depth" value="3"/>
        </properties>
    </persistence-unit>
</persistence>

当我将应用程序部署到Glassfish时,它抱怨... Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application,but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan,e.g.) is available on the classpath.

还有其他可以设置的地方吗?

mattkk 回答:无法删除Hibernate二级缓存?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3156341.html

大家都在问