想知道CSDN网友的答案,算作散点分。

解决方案 »

  1.   

    Hibernate 内部有配置参数,他会自动批量更新的。 具体那个自己去查
      

  2.   

    Hibernate 内部有配置参数,他会自动批量更新的。 具体那个自己去查
      

  3.   

    再贴一次hibernate的帮助
    13.1. 批量插入(Batch inserts)
    如果要将很多对象持久化,你必须通过经常的调用 flush() 以及稍后调用 clear() 来控制第一级缓存的大小。 Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
       
    for ( int i=0; i<100000; i++ ) {
        Customer customer = new Customer(.....);
        session.save(customer);
        if ( i % 20 == 0 ) { //20, same as the JDBC batch size //20,与JDBC批量设置相同
            //flush a batch of inserts and release memory:
            //将本批插入的对象立即写入数据库并释放内存
            session.flush();
            session.clear();
        }
    }
       
    tx.commit();
    session.close();13.2. 批量更新(Batch updates)
    此方法同样适用于检索和更新数据。此外,在进行会返回很多行数据的查询时, 你需要使用 scroll() 方法以便充分利用服务器端游标所带来的好处。 Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
       
    ScrollableResults customers = session.getNamedQuery("GetCustomers")
        .setCacheMode(CacheMode.IGNORE)
        .scroll(ScrollMode.FORWARD_ONLY);
    int count=0;
    while ( customers.next() ) {
        Customer customer = (Customer) customers.get(0);
        customer.updateStuff(...);
        if ( ++count % 20 == 0 ) {
            //flush a batch of updates and release memory:
            session.flush();
            session.clear();
        }
    }
       
    tx.commit();
    session.close();
      

  4.   

    http://www.baidu.com/s?wd=%C5%FA%C1%BF%CC%E1%BD%BB+Hibernate
    网上不是很多么
      

  5.   

    <!-- 设置批量更新处理参数 -->
    <property name="jdbc.batch_size">4</property>
    <property name="cache.use_second_level_cache">fale</property>把这个写在hibernate.cfg.xml中
      

  6.   


    直接配置这个jdbc.batch_size属性Hibernate就会自动处理了吗?为什么cache.use_second_level_cache 这个属性设置false?