-
Jul 10th, 2012, 02:35 AM
#1
no persistence.xml and JTA
Hi!
I'm very glad that in Spring 3.1 i dont't have to use persistence.xml file.
I have persistence unit configured within applicationContext.xml and Hibernate 3.6.5 as JPA provider.
I should use JTA and I have a problem- where should I put something like transaction-type="JTA" (formerly it was in persistence.xml file).
I've impelmented my own PersistenceUnitPostProcessor according to:
http://springtips.blogspot.com/2008/...n-jta-and.html
but i'd like to know is there better or simpler (or maybe cool ;-)) way to inform JPA that want to use JTA instead of RESOURCE_LOCAL.
Is there some property in jpaPropertyMap or maybe something else...
Best regards,
Zwirek
P.S.
My EntityManagerFactory configuration:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter"
p:database="ORACLE" p:showSql="false" />
</property>
<property name="packagesToScan" ref="packagesToScanArray" />
<property name="mappingResources" ref="mappingResourcesArray" />
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionM anagerLookup" />
<entry key="hibernate.hbm2ddl.auto" value="none" />
<entry key="hibernate.format_sql" value="true" />
<entry key="hibernate.cache.region.factory_class" value="net.sf.ehcache.hibernate.EhCacheRegionFacto ry" />
<entry key="hibernate.cache.use_query_cache" value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="true" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.cache.provider_configuration_file_r esource_path" value="/ehcache.xml" />
<entry key="hibernate.jdbc.use_streams_for_binary" value="true" />
<entry key="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
</map>
</property>
<property name="persistenceUnitPostProcessors">
<list>
<bean class="jpautil.JtaPersistenceUnitPostProcessor">
<property name="jtaMode" value="true"></property>
<property name="jtaDataSource" ref="dataSource"></property>
</bean>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager">
<property name="transactionManagerName" value="java:/TransactionManager" />
<property name="userTransactionName" value="UserTransaction" />
</bean>
Last edited by zwirek777; Jul 17th, 2012 at 10:21 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules