(I am asking the same question at StackOverflow too:
http://stackoverflow.com/questions/1...bean-hibernate )
I have did a lot of search on the web and pages like this and this and this mostly suggested for using CMTTransactionFactory. However I am still unable to make it work (I wonder if it is because I am creating a EM using a LocalContainerEntityManagerFactoryBean instead of creating Hibernate session by LocalSessionFactoryBean)
Here is what I have in my app ctx
(In jpaPropertyMap, I tried to have the two remarked entries and still the same)Code:<jee:jndi-lookup id="dataSource" jndi-name="jdbc/fooDs" /> <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" /> <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /> </bean> </property> <property name="persistenceUnitName" value="foo" /> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="com.foo" /> <!-- <property name="persistenceXmlLocation" value="classpath:/META-INF/test-persistence.xml" /> --> <property name="jpaPropertyMap"> <map> <entry key="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <!-- <entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" /> <entry key="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/> --> <entry key="hibernate.transaction.factory_class" value="org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory"/> <entry key="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform"/> <entry key="hibernate.transaction.flush_before_completion" value = "true" /> </map> </property> </bean>
I am making use of Spring Data JPA and after the entity is retrieved, I updated the content. If I am not flushing the repository (which means session/entityManager) manually, it simply discard my changes.
Can anyone give me some hints on what I have missed in the setting? Is there anything special to notice for using LocalContainerEntityManagerFactoryBean?
I am using Spring 3.1.2.RELEASE, Hibernate 4.1.6.Final, Websphere 8


Reply With Quote
