日期:2014-05-16 浏览次数:20380 次
@GeneratedValue(strategy = GenerationType.TABLE,generator="customer_gen") @TableGenerator(name = "customer_gen", table="tb_generator", pkColumnName="gen_name", valueColumnName="gen_value", pkColumnValue="testtable_PK" )
@Override public void saveTestData(int sum) { /* DELETE FROM dbo.testtable3; DELETE FROM dbo.testtable2; DELETE FROM dbo.testtable1; DELETE FROM dbo.testtable; */ Date d1 = new Date(); //单表 for(int i=0; i<sum; i++){ Testtable t = new Testtable(); t.setCode("Test"+i); testtableDao.save(t); //System.out.println("自定义主键生成 记录:"+i+" 单表:"+(new Date()).toString()); } System.out.println("完成单表操作"); //关联 for(int i=0; i<sum; i++){ Testtable1 p = new Testtable1(); p.setCode("P"+i); p = testtable1Dao.save(p); Testtable2 c = new Testtable2(); c.setTesttable1(p); c.setCode("C"+i); testtable2Dao.save(c); //System.out.println("自定义主键生成 记录:"+i+" 关联:"+(new Date()).toString()); } System.out.println("完成关联操作"); //映射 for(int i=0;i<sum; i++){ Testtable t = new Testtable(); t.setCode("T"+i); t = testtableDao.save(t); Testtable2 c = new Testtable2(); c.setCode("C"+i); c = testtable2Dao.save(c); Testtable3 m = new Testtable3(); m.setCode("M"+i); m.setTesttable(t); m.setTesttable2(c); m = testtable3Dao.save(m); //System.out.println("自定义主键生成 记录:"+i+" 映射:"+(new Date()).toString()); } System.out.println("完成映射操作"); System.out.println("Over......"); Date d2 = new Date(); long t = d2.getTime() - d1.getTime(); System.out.println("service耗时=" + (t / 1000) + "s"); }
@GeneratedValue(strategy = GenerationType.AUTO)
@Override public void saveTestData(int sum) { /* DELETE FROM dbo.atabletest3; DELETE FROM dbo.atabletest2; DELETE FROM dbo.atabletest1; DELETE FROM dbo.atabletest; */ Date d1 = new Date(); //单表 for(int i=0; i<sum; i++){ Atabletest t = new Atabletest(); t.setCode("Test"+i); atabletestDao.save(t); //System.out.println("数据库主键生成 记录:"+i+" 单表:"+(new Date()).toString()); } System.out.println("完成单表操作"); //关联 for(int i=0; i<sum; i++){ Atabletest1 p = new Atabletest1(); p.setCode("P"+i); p = atabletest1Dao.save(p); Atabletest2 c = new Atabletest2(); c.setAtabletest1(p); c.setCode("C"+i); atabletest2Dao.save(c); //System.out.println("数据库主键生成 记录:"+i+" 关联:"+(new Date()).toString()); } System.out.println("完成关联操作"); //映射 for(int i=0;i<sum; i++){ Atabletest t = new Atabletest(); t.setCode("T"+i); t = atabletestDao.save(t); Atabletest2 c = new Atabletest2(); c.setCode("C"+i); c