initDatabaseStopWatch.start();
BatchSupport batchSupport = new BatchSupport( sf );
batchSupport.execute( "insert into author(id, name) values(?, ?)", initialAutorCount,
new BatchCallback() {
@Override
public void initStatement(PreparedStatement ps, long id) throws SQLException {
ps.setLong( 1, id );
ps.setString( 2, "autor" + id );
}
} );
batchSupport.execute( "insert into book(id, title, summary, rating, totalSold, publicationDate) values(?, ?, ?, ?, ?, ?)", initialBookCount,
new BatchCallback() {
@Override
public void initStatement(PreparedStatement ps, long id) throws SQLException {
ps.setLong( 1, id );
ps.setString( 2, "title" + id );
ps.setString( 3, reverse( SUMMARIES[(int) ( id % SUMMARIES.length )] ) );
ps.setLong( 4, -1 );
ps.setLong( 5, -1 );
ps.setDate( 6, new Date( PUBLICATION_DATE_ZERO.getTime() ) );
}
} );
batchSupport.execute( "insert into book_author(book_id, authors_id) values(?, ?)", initialBookCount,
new BatchCallback() {
@Override
public void initStatement(PreparedStatement ps, long id) throws SQLException {
ps.setLong( 1, id );
ps.setLong( 2, initialOffset + ( id % initialAutorCount ) );
}