Skip to content

Instantly share code, notes, and snippets.

@dileeph
Created June 28, 2012 14:57
Show Gist options
  • Save dileeph/3011824 to your computer and use it in GitHub Desktop.
Save dileeph/3011824 to your computer and use it in GitHub Desktop.
JOOQ - Batch inserting a list of records (not shown in JOOQ tutorial)
@Test
public void testBatch(){
/*Preparing sample data. */
MzRolesRecord admin = new MzRolesRecord();
admin.setCreatedDate(new Timestamp(System.currentTimeMillis()));
admin.setRoleDesc("Admin");
MzRolesRecord user = new MzRolesRecord();
user.setCreatedDate(new Timestamp(System.currentTimeMillis()));
user.setRoleDesc("User");
List<MzRolesRecord> roles = Lists.newArrayList(admin,user);
/*Now to actual batch insert.*/
int[] updates = mzFactory.batchStore(roles).execute();
Assert.assertEquals(2, updates.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment