-------->接上贴
applicationContext.xml如下:
<?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.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@172.19.17.237:1521:ora10g64</value>
</property>
<property name="username">
<value>yy</value>
</property>
<property name="password">
<value>yy</value>
</property>
</bean>
<!-- Transaction manager for a single JDBC DataSource -->
<!-- (see dataAccessContext-jta.xml for an alternative) -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean> <!-- SqlMap setup for iBATIS Database Layer -->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>com/excellence/yyzwbm/partyorgan/labourunion/bean/iBatis-config.xml</value>
</property>
</bean>
<!-- Need to set the singleton attributr of sequenceDao to false ... er ... for efficiency -->
<!-- DAO-->
<bean id="superDao" abstract="true">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
<bean id="unionistDAO" class="com.excellence.yyzwbm.partyorgan.labourunion.dao.UnionistDAO" parent="superDao"/>
<!---->
 <bean id="unionistServiceImpl" class="com.excellence.yyzwbm.partyorgan.labourunion.service.UnionistServiceImpl">
<property name="unionistDAO">
<ref local="unionistDAO"/>
</property>
</bean>
<!-- -->
<bean id="unionistServiceProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="target">
<ref local="unionistServiceImpl"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>
测试类如下:
public class TestLabourUnion {
public static void main(String[] args) {
IUnionistService service = BeanFactory.getUnionistService();
UnionistVO vo = new UnionistVO();
vo.setPersonId("p001");
vo.setMemberId("0001");
vo.setDuty("工会主席");
vo.setLgInDate(new Date(System.currentTimeMillis()));
System.out.println("开始操作数据库:");
UnionistVO vo1 = service.insertUnionist(vo);
System.out.println("插入的数据如下:");
System.out.println("人员编号:"+vo1.getPersonId());
System.out.println("*********finished!*******");
}
}