java - Hibernate batch insert a list into a table which has unique column -


i hava list contains 1,000,000 records.

i want insert list table have 5,000,000 records.

the code:

sample s = null; for(int i=0,len=list.size();i<list;i++){   s = new sample();   session.save(s);   if(i%20==0){     session.flush();     session.clear();   } } 

a column in table unique column.

some records in list same records in table.

like this:

list : ['a','b','c']...

table : ['a','d','e']...

'a' duplicate, code can't word well.

exception: don't flush session after exception occurs

it's sloooooooooooow use this:

string sql = 'insert ignore xxxxx'; session.createsqlquery().executeupdate(); 

how should do? me, please~~~


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -