Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Spring Configuration file using Data Source for JUnit Test Cases...........

 
Greenhorn
Posts: 10
Hibernate Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">;


<beans>
<!--
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbcracle:thin:@192.168.44.111:1521:SCHEMA</value>
</property>
<property name="username">
<value>username</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>

--><!-- JunitJdbc.properties -->
<!-- <bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="JunitJdbc.properties" />
</bean> -->

<!-- Local DataSource that works in any environment -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@192.168.44.66:1521:SCHEMA" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="maxIdle" value="5" />
<property name="maxActive" value="90" />
<property name="minIdle" value="5" />

</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">



<property name="mappingLocations">
<!-- Common HBM's i.e not specific to module -->
<list>
<value>classpath*:com/pkg1/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg2/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg3/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg4/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg5/hbm/*.hbm.xml</value>
<value>classpath*:com/pkg6/hbm/*.hbm.xml</value>
</list>
</property>

<property name="mappingResources">
<!-- Local HBM's i.e specific module hbms -->
<list>
<value>pkgtest/abc.hbm.xml</value>
<value>pkgtest/asd.hbm.xml</value>
<value>pkgtest/ert.hbm.xml</value>
<value>pkgtest/sdas.hbm.xml</value>


</list>

</property>

<property name="hibernateProperties">
<props>
<prop key="connection.provider_class">
org.hibernate.connection.DatasourceConnectionProvider
</prop>
<prop key="jdbc.use_streams_for_binary">true</prop>
<prop key="jdbc.batch_size">0</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle10gDialect
</prop>
<prop key="hibernate.query.substitutions">
true 1, false 0
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.cache.use_second_level_cache">
false
</prop>
<prop key="hibernate.cache.use_minimal_puts">
false
</prop>
<!-- Todd Albee: setting use_query_cache conflicts with SwarmCache -->
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibenrate.cache.use_structured_entries">
true
</prop>
<prop key="hibernate.connection.release_mode">
auto
</prop>

<!-- for backward compatibility of hql queries -->
<prop key="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>

<!-- we get UserTransaction not bound to JNDI error -->


<prop key="hibernate.generate_statistics">true</prop>

</props>
</property>

<property name="dataSource">
<ref bean="dataSource" />

</property>

<property name="eventListeners">
<map>
<entry key="merge">
<bean
class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
</entry>
</map>
</property>
</bean>



<!-- Added for transaction starts here -->


<bean id="baseTransactionService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>


<!-- Added for transaction ends here -->






<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>





<!-- Service, DAO layer configuration starts here -->
<bean id="myService" class="MyServiceImpl">
<property name="myDAO" ref="myDAO" />
</bean>

<bean id="myDAO" class="MyDAOImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- Service,DAO layer configuration ends here -->


</beans>
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is the question?
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you have a question, please be sure to state it clearly and with all required details. Please read this for more information.

This topic is closed to give the poster another chance to post a new topic with necessary details.
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic