Thought I’d post a snippet of applicationContext.xml for all the people out there trying a JNDI data source wired up in IBM’s WebSphere Application Server through Spring Framework and Hibernate. I couldn’t find this information as a whole anywhere out there so hopefully it helps someone.
Hit the jump for the xml.
<beans>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/DB2"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- IBM WAS SPECIFIC -->
<prop key="hibernate.connection.datasource">jdbc/DB2</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</prop>
<!-- /END IBM WAS SPECIFIC -->
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="autodetectTransactionManager" value="false" />
</bean>
</beans>
thank you so much. I learning from your setting now, it is interesting, because there are many kinds of setting, yours looks good.
How to get it and use it?
Nice post!
Have you seen though this article? (google for ’0609_alcott’)
http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html
Is not clear to me whether your recommended settings and the ones in the article are equivalent.
Bruce, I had not seen that bit from IBM. I pieced together this recommendation based on several articles and my personal experience at a client site. That article appears to be more thorough and if my settings don’t function in your application I would defer to the article as your specific implementation may need extended settings.