JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()

ⅰ亾dé卋堺 提交于 2019-11-29 11:54:33

As far as I'm aware,it is not possible to configure Hibernate JPA with JTA support using Spring unless you provide a persistence.xml in order to configure the datasource as JTA. Perhaps some thing like this will help you get rid of the warning:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
    <persistence-unit name="something" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>blah blah</jta-data-source>
        <properties>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.current_session_context_class" value="jta"/>
            <property name="hibernate.transaction.manager_lookup_class" value="blah blah"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>          
            <property name="hibernate.connection.release_mode" value="after_statement"/>
        </properties>
    </persistence-unit>
</persistence>

I would also suggest you to disable allowLocalTransactions so that your code will run as transactional all the time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!