日期:2014-05-20 浏览次数:20760 次
application.xml
<context:component-scan base-package="daoImpl" />
<!-- 使用aop -->
<aop:aspectj-autoproxy />
<aop:config>
<aop:advisor pointcut="execution(* daoImpl.*.*(..))"
advice-ref="txAdvice" />
</aop:config>
<!--hibernate的事务处理管理 -->
<!-- -->
<tx:annotation-driven transaction-manager="transactionManager" />
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:myself"/>
<property name="username" value="root"/>
<property name="password" value="123"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<!-- <prop key="current_session_context_class">thread</prop> -->
<prop key="cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
</props>
</property>
public class test {
/**
* @param args
*/
@Test
public static void main(String[] args) {
// TODO Auto-generated method stub
File file = new File("D:\\done2220130901172241.txt");
ApplicationContext ac = new ClassPathXmlApplicationContext(