<?xml version="1.0" encoding="UTF-8"?>
<beans>
<!--定义Hibernate参数 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.ibm.db2.jcc.DB2Driver</value>
<!-- MYSQL的驱动
<value>com.mysql.jdbc.Driver</value>
-->
<!-- SQL SERVER的驱动
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
-->
</property>
<property name="url">
<value>jdbc:db2://localhost:50000/film</value>
<!-- <value>jdbc:db2:film</value>-->
<!-- 连接 Microsoft SQL Server 2000
<value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=registration</value>
-->
</property>
<property name="username">
<!-- <value>root</value> -->
<value>root</value>
<!--<value>db2admin</value>-->
</property>
<property name="password">
<value>987654321</value>
</property>
<property name="maxActive">
<value>30</value>
</property>
<property name="maxWait">
<value>30000</value>
</property>
<property name="defaultAutoCommit">
<value>false</value>
</property>
<property name="defaultReadOnly">
<value>false</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<!-- DB2数据库方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
<!-- MYSQL数据库方言
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>-->
<!-- SQL SERVER数据库方言
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
-->
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>model/Admin.hbm.xml</value>
<value>model/Spectator.hbm.xml</value>
<value>model/Hall.hbm.xml</value>
<value>model/Ticket.hbm.xml</value>
<value>model/Film.hbm.xml</value>
</list>
</property>
</bean>
<!--定义Hibernate参数 -->
<!-- 向BaseDAO的实现类注入SessionFactory-->
<bean id="BaseHibernateDAO" class="dao.impl.BaseHibernateDAO" lazy-init="false" singleton="true">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 向BaseDAO的实现类注入SessionFactory-->
<!-- 管理员DAO -->
<bean id="AdminDAO" class="dao.impl.AdminDAO" >
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 管理员DAO -->
<!-- 电影DAO -->
<bean id="FilmDAO" class="dao.impl.FilmDAO" >
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 电影DAO -->
<!-- 放映厅DAO -->
<bean id="HallDAO" class="dao.impl.HallDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 放映厅DAO -->
<!-- 电影票DAO -->
<bean id="TicketDAO" class="dao.impl.TicketDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 电影票DAO -->
<!-- 观众DAO -->
<bean id="SpectatorDAO" class="dao.impl.SpectatorDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 电影票DAO -->
<!-- 注入服务xxxServiceImpl之开始 -->
<bean id="AdminServiceImpl" class="service.impl.AdminServiceImpl" lazy-init="false" singleton="true">
<property name="adminDAO">
<ref bean="AdminDAO"/>
</property>
</bean>
<bean id="FilmServiceImpl" class="service.impl.FilmServiceImpl" lazy-init="false" singleton="true">
<property name="filmDAO">
<ref bean="FilmDAO"/>
</property>
<property name="baseDAO">
<ref bean="BaseHibernateDAO"/>
</property>
</bean>
<bean id="HallServiceImpl" class="service.impl.HallServiceImpl" lazy-init="false" singleton="true">
<property name="hallDAO">
<ref bean="HallDAO"/>
</property>
<property name="baseDAO">
<ref bean="BaseHibernateDAO"/>
</property>
</bean>
<bean id="TicketServiceImpl" class="service.impl.TicketServiceImpl" lazy-init="false" singleton="true">
<property name="ticketDAO">
<ref bean="TicketDAO"/>
</property>
<property name="baseDAO">
<ref bean="BaseHibernateDAO"/>
</property>
</bean>
<bean id="SpectatorServiceImpl" class="service.impl.SpectatorServiceImpl" lazy-init="false" singleton="true">
<property name="spectatorDAO">
<ref bean="SpectatorDAO"/>
</property>
<property name="baseDAO">
<ref bean="BaseHibernateDAO"/>
</property>
</bean>
<!-- 注入服务xxxServiceImpl之结束 -->
<!-- 注入事务 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="adminServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="AdminServiceImpl" />
</property>
<property name="transactionAttributes">
<props>
<prop key="show*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="filmServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="FilmServiceImpl" />
</property>
<property name="transactionAttributes">
<props>
<prop key="show*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="hallServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="HallServiceImpl" />
</property>
<property name="transactionAttributes">
<props>
<prop key="show*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="spectatorServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="SpectatorServiceImpl" />
</property>
<property name="transactionAttributes">
<props>
<prop key="show*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="ticketServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="TicketServiceImpl" />
</property>
<property name="transactionAttributes">
<props>
<prop key="show*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- 注入事务 -->
</beans>
[此贴子已经被作者于2007-1-12 0:47:44编辑过]