spring 配置 JTA
环境JBOSS4 数据源名称为 MysqlDs
<jee:jndi-lookup id="dataSource" jndi-name="java:MysqlDs" />
?? ?<bean id="sessionFactory"
?? ??? ?/>
?? ??? ?</property>?? ?
?? ??? ?<property name="hibernateProperties">
?? ??? ??? ?<props>
?? ??? ??? ??? ?<prop key="hibernate.dialect">
?? ??? ??? ??? ??? ?${hibernate.dialect}
?? ??? ??? ??? ?</prop>
?? ??? ??? ??? ?<prop key="hibernate.show_sql">
?? ??? ??? ??? ??? ?${hibernate.show_sql}
?? ??? ??? ??? ?</prop>
?? ??? ??? ?</props>
?? ??? ?</property>
?? ??? ?<!-- 此种映射方式更好,也能读取jar中的映射文件 -->
?? ??? ?<property name="mappingLocations">
?? ??? ??? ?<list>
?? ??? ??? ??? ?<value>classpath:com/test/model/hbm/*.hbm.xml</value>?? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ?</list>
?? ??? ?</property>
?? ??? ?<!--
?? ??? ?<property name="mappingDirectoryLocations">
?? ??? ??? ?<list>
?? ??? ??? ??? ?<value>classpath:com/test/model/hbm/</value>?? ??? ??? ?
?? ??? ??? ?</list>
?? ??? ?</property>
?? ??? ? -->
?? ?</bean>
?? ?<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
?? ?<property name="userTransactionName">? <!-- 这里很重要-->
?? ??? ?<value>java:comp/UserTransaction</value> ?
?? ?</property> ?
?? ?</bean>