Methods Summary |
---|
public void | configure(org.hibernate.cfg.Configuration cfg)
super.configure( cfg );
cfg.setProperty( Environment.ORDER_INSERTS, "true" );
cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, "10" );
cfg.setProperty( Environment.BATCH_STRATEGY, StatsBatcherFactory.class.getName() );
|
public java.lang.String[] | getMappings()
return new String[] { "insertordering/Mapping.hbm.xml" };
|
public static junit.framework.Test | suite()
return new FunctionalTestClassTestSuite( InsertOrderingTest.class );
|
public void | testBatchOrdering()
Session s = openSession();
s.beginTransaction();
int iterations = 12;
for ( int i = 0; i < iterations; i++ ) {
User user = new User( "user-" + i );
Group group = new Group( "group-" + i );
s.save( user );
s.save( group );
user.addMembership( group );
}
StatsBatcher.reset();
s.getTransaction().commit();
s.close();
assertEquals( 6, StatsBatcher.batchSizes.size() ); // 2 batches of each insert statement
s = openSession();
s.beginTransaction();
Iterator users = s.createQuery( "from User u left join fetch u.memberships m left join fetch m.group" ).list().iterator();
while ( users.hasNext() ) {
s.delete( users.next() );
}
s.getTransaction().commit();
s.close();
|