Java tutorial
/** * Copyright (c) 2013-2015 www.javahih.com * * Licensed under the Apache License, Version 2.0 (the "License"); */ package com.hihsoft.sso.business.service; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import com.hihsoft.sso.business.model.TsysModuleinfo; import com.hihsoft.sso.business.service.TsysModuleinfoService; import com.hihsoft.sso.util.BaseTestCase; /** * <p> Title:? </p> * <p> Description:??</p> * <p> Copyright: Copyright (c) 2013 </p> * <p> Company:hihsoft.co.,ltd </p> * * @author zhujw * @version 1.0 */ public class TaclModuleinfoServiceTestCase extends BaseTestCase { /** The tacl role service. */ @Autowired public static TsysModuleinfoService tsysModuleinfoService; /**??:hibernate5000??spring???<50000? * 4000???CPU * Testsave or update tacl role. */ @Test public void testsaveOrUpdateTaclModuleinfo() { TsysModuleinfo moduleinfo = null; // Session Configuration cfg = new Configuration(); SessionFactory sf = cfg.configure().buildSessionFactory(); Session session = sf.openSession(); // Transaction tx = session.beginTransaction(); // 100 000?100 000? for (int i = 1000000; i < 2000000; i++) { // Moduleinfo moduleinfo = new TsysModuleinfo(); moduleinfo.setModulename("moduleinfo" + i); moduleinfo.setModulename("00000001" + i); moduleinfo.setFlatid("8a9e848a2ed74230012ed7424737000a"); session.save(moduleinfo); // ?20?Session??Session if (i % 5000 == 0) { session.flush(); session.clear(); tx.commit(); tx = session.beginTransaction(); } } // ?? tx.commit(); // session.close(); } /** * Test query moduleinfo. */ @Test public void testQueryModuleinfo() { log.info(tsysModuleinfoService.getAllTsysModuleinfo()); } }