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.
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>
One Comment
thank you so much. I learning from your setting now, it is interesting, because there are many kinds of setting, yours looks good.