锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
public class AddMoreWords {
聽(tīng)private static String type = "idiom";
聽(tīng)/**
聽(tīng) * @param args
聽(tīng) */
聽(tīng)public static void main(String[] args) throws Exception {
聽(tīng)聽(tīng)// TODO Auto-generated method stub
聽(tīng)聽(tīng)
聽(tīng)聽(tīng)Session session = HibernateSessionFactory.currentSession();
聽(tīng)聽(tīng)Transaction txc = session.beginTransaction();
聽(tīng)聽(tīng)for(int i=0;i<1000;++i){
聽(tīng)聽(tīng)聽(tīng)WordLib word = new WordLib();
聽(tīng)聽(tīng)聽(tīng)word.setChn("mm"+(i+1));
聽(tīng)聽(tīng)聽(tīng)word.setTime(new Date());
聽(tīng)聽(tīng)聽(tīng)word.setType(type);
聽(tīng)聽(tīng)聽(tīng)session.save(word);
聽(tīng)聽(tīng)聽(tīng)if((i+1)%25 == 0){
聽(tīng)聽(tīng)聽(tīng)聽(tīng)session.flush();
聽(tīng)聽(tīng)聽(tīng)聽(tīng)session.clear();
聽(tīng)聽(tīng)聽(tīng)}
聽(tīng)聽(tīng)}
//聽(tīng)聽(tīng)WordLib word = new WordLib();
//聽(tīng)聽(tīng)word.setChn("a");
//聽(tīng)聽(tīng)word.setTime(new Date());
//聽(tīng)聽(tīng)word.setType(type);
//聽(tīng)聽(tīng)session.save(word);
聽(tīng)聽(tīng)txc.commit();
聽(tīng)聽(tīng)HibernateSessionFactory.closeSession();
聽(tīng)聽(tīng)session.flush();
聽(tīng)聽(tīng)session.close();
聽(tīng)}
}