日期:2014-05-18 浏览次数:20967 次
SessionFactory sf = hibernateTemplate.getSessionFactory();
//session不是从事务中获取的、自己新创个、
Session session = sf.openSession();
session.getTransaction().begin();
long s = System.currentTimeMillis();
//循环保存、累积一起提交事务 time++
session.getTransaction().commit();
long e = System.currentTimeMillis();
System.out.println("共执行了"+time+"行数据用时:"+(e-s)+"ms");
session.flush();
session.clear();
session.close();
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
<property name="cacheQueries" value="true"/>
<property name="fetchSize" value="100"/>
<property name="maxResults" value="10000"/>
</bean>
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass">