在休眠3.5.6中将Flush模式从AUTO设置为COMMIT

时间:2017-02-08 07:34:20

标签: java hibernate jpa ejb-3.0 jboss6.x

我想在persistence.xml文件中将刷新模式从默认 AUTO 设置为 COMMIT , 我一个接一个地试过以下属性,

        <property name="org.hibernate.FlushMode" value="COMMIT"/> 

        <property name="org.hibernate.flushMode" value="COMMIT"/>  

        <property name="org.hibernate.flushMode" value="commit"/>   

        <property name="hibernate.flushMode" value="COMMIT"/>

        <property name="hibernate.transaction.flush_before_completion">true</property> 

但它们似乎都没有用。我使用下面的代码检查了flushmode,

Sysout(((Session)entityManager.getDelegate()).getFlushMode().toString());

我们正在使用 JPA版本:hibernate-jpa-2.0-api-1.0.0.Final hibernate版本:3.5.6

这里是我的persistence.xml文件的属性标记:

<properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
        <property name="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
        <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

        <!-- EhCache cache for level 2 -->
        <property name="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.EhCacheRegionFactory"/>

        <!-- To support multiple cache manager in the same VM   -->
        <property name="net.sf.ehcache.configurationResourceName" value="ehcache-test.xml"></property>

        <!--  Enable second level cache -->
        <property name="hibernate.cache.use_second_level_cache" value="false"/>

        <!-- <property name="org.hibernate.FlushMode" value="COMMIT"/> -->

        <property name="org.hibernate.flushMode" value="COMMIT"/>   
        <!-- <property name="hibernate.flushMode" value="COMMIT"/> -->

        <!-- <property name="hibernate.transaction.flush_before_completion">true</property> -->

        <!--  Enable query cache -->
        <property name="hibernate.cache.use_query_cache" value="true"/> 

        <property name="hibernate.id.new_generator_mappings" value="true"/>

        <!-- Showing queries generated by Hibernate                            
        <property name="hibernate.show_sql" value="true"/>    
        <property name="hibernate.format_sql" value="true"/> 
        <property name="use_sql_comments" value="true" />--> 

    <!--<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jbc2.JndiMultiplexedJBossCacheRegionFactory"/>
        <property name="hibernate.cache.region.jbc2.cachefactory" value="java:CacheManager"/>
        <property name="hibernate.cache.region.jbc2.cfg.entity" value="mvcc-entity"/>
        <property name="hibernate.cache.region.jbc2.cfg.query" value="local-query"/> 
        <property name="hibernate.cache.region_prefix" value="ScoringJPA"/>--> 

    </properties>

0 个答案:

没有答案