since the project last night batch job extraction data primary key generator problem, emergency resolution with sequence as the primary key.
The underlying uses MyBatis to interact with the Oracle database library. she talked with her for a long time and she didn't give a solution. to be
This himself wrote a way of thinking, and did not expect a test to pass completely.
The approximate demo is as follows
- Java code
1 /**2 * File name: Insertbatch3 * Content Summary: Test MyBatis Using series BULK INSERT4 * Create person: Sunrise5 * Date Created: 2015-6-18 pm 9:16:066 * Modify record 1://Modify history, including date of modification, modified by, and modified content7 * Date Modified:8 * Version number:9 * Modify Person:Ten * What to modify: One * Change record 2: ... A */ -@TransactionConfiguration (TransactionManager = "TransactionManager", Defaultrollback =false) - Public classInsertbatchextends the springtransactionaltestcasewithallcontextconfiguration { - - Private StaticLogger Logger = Loggerfactory.getlogger (insertbatch.class); - @Autowired + datacomponent datacomponent; - @Test + Public voidTest () A { at - intCount = 0;//article number - LongStartime;//Time -list<map<string,string>> list =NewArraylist<map<string,string>>(); - Do - { inMap<string,string> map=NewHashmap<string,string>(); -Map.put ("Dept_name", "Xgy"); to list.add (map); +count++; -} while(count<2000); the *Logger.info (">>>>>>>>>>>>>>>>>>>>>>>> > Star "); $Startime =System.currenttimemillis ();Panax NotoginsengSunrise.insertdata ("SDA. Hisdatahandle.xgy ", list); -Logger.info (">>>>>>>>>>>>>>>> this insert: {}; time-consuming: {}", Count, theSystem.currenttimemillis ()-startime); +Logger.info (">>>>>>>>>>>>>>>>>>>>>>>> > Over "); A } the}
- SQL XML
<!--test SQL--
<InsertID= "Xgy"ParameterType= "List">INSERT INTO Sunrise (ID, dept_name) with t a S (<foreachCollection= "List"Item= "Item"Index= "Index"Separator= "UNION All" >Select #{item. Dept_name} Dept_name from dual</foreach>) Select Seq_sunrise. Nextval,t.dept_name from T</Insert>
- Log
[INFO] 15-06-18 21:32:25,446 [Com.sunrise.test.dao.InsertBatch] ->>>>>>>>>>> >>>>>>>>>>>>>> Star[info] 15-06-18 21:32:25,759 [ Com.ophiux.test.dao.InsertBatch] ->>>>>>>>>>>>>>>> This insert: 2000; time: 312[info] 15-06-18 21:32:25,760 [Com.sunrise.test.dao.InsertBatch] ->>>>>>> >>>>>>>>>>>>>>>>>> over
- Database
MyBatis Oracle BULK INSERT database using sequences