Skip to content

Instantly share code, notes, and snippets.

@billdozr
Created December 18, 2009 09:53
Show Gist options
  • Save billdozr/259405 to your computer and use it in GitHub Desktop.
Save billdozr/259405 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!-- Data Source Setup -->
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-
method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/
<property name="url" value="jdbc:hsqldb:file:dev_db/myapp-
testdb"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>mappings.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.hbm2ddl.auto=update
</value>
</property>
</bean>
<bean id="namingStrategy"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean" >
<property name="staticField">
<value>org.hibernate.cfg.ImprovedNamingStrategy.INSTANCE</
value>
</property>
</bean>
<bean id="extendedFinderNamingStrategy"
class="com.myapp.core.persist.dao.finder.impl.ExtendedFinderNamingStrategy" /
<!-- Dao Layer generic config-->
<bean id="finderIntroductionAdvisor"
class="com.myapp.core.persist.dao.finder.impl.FinderIntroductionAdvisor"/
<bean id="abstractDaoTarget"
class="com.myapp.core.persist.dao.impl.GenericDaoHibernateImpl"
abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="namingStrategy">
<ref bean="extendedFinderNamingStrategy" />
</property>
</bean>
<bean id="abstractDao"
class="org.springframework.aop.framework.ProxyFactoryBean"
abstract="true">
<property name="interceptorNames">
<list>
<value>finderIntroductionAdvisor</value>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributeSource">
<value>
com.myapp.core.persist.dao.impl.GenericDaoHibernateImpl.create=PROPAGATION_ REQUIRED
com.myapp.core.persist.dao.impl.GenericDaoHibernateImpl.update=PROPAGATION_ REQUIRED
com.myapp.core.persist.dao.impl.GenericDaoHibernateImpl.delete=PROPAGATION_ REQUIRED
</value>
</property>
</bean>
<!-- Dao Layer instances -->
<bean id="labelDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.myapp.core.persist.dao.LabelDao</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.myapp.core.model.Label</value>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="emailAddressDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.myapp.core.persist.dao.EmailAddressDao</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.myapp.core.model.EmailAddress</value>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="senderDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.myapp.core.persist.dao.SenderDao</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.myapp.core.model.Sender</value>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="billDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.myapp.core.persist.dao.BillDao</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.myapp.core.model.Bill</value>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="powerBillDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.myapp.core.persist.dao.PowerBillDao</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.myapp.core.model.PowerBill</value>
</constructor-arg>
</bean>
</property>
</bean>
<!-- Business Layer instances -->
<!-- ... -->
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment