HHH-7841 - Redesign Loader

This commit is contained in:
Steve Ebersole 2013-03-27 08:29:24 -05:00
parent 1b10ee72f5
commit 88d5c02d7f
1 changed files with 14 additions and 6 deletions

View File

@ -44,6 +44,7 @@ import org.hibernate.jdbc.Work;
import org.hibernate.loader.entity.BatchingEntityLoaderBuilder; import org.hibernate.loader.entity.BatchingEntityLoaderBuilder;
import org.hibernate.loader.entity.EntityLoader; import org.hibernate.loader.entity.EntityLoader;
import org.hibernate.loader.internal.ResultSetProcessorImpl; import org.hibernate.loader.internal.ResultSetProcessorImpl;
import org.hibernate.loader.plan.internal.EntityLoadQueryImpl;
import org.hibernate.loader.plan.internal.SingleRootReturnLoadPlanBuilderStrategy; import org.hibernate.loader.plan.internal.SingleRootReturnLoadPlanBuilderStrategy;
import org.hibernate.loader.plan.spi.LoadPlan; import org.hibernate.loader.plan.spi.LoadPlan;
import org.hibernate.loader.plan.spi.LoadPlanBuilder; import org.hibernate.loader.plan.spi.LoadPlanBuilder;
@ -71,6 +72,8 @@ public class SimpleResultSetProcessorTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testSimpleEntityProcessing() throws Exception { public void testSimpleEntityProcessing() throws Exception {
final EntityPersister entityPersister = sessionFactory().getEntityPersister( SimpleEntity.class.getName() );
// create some test data // create some test data
Session session = openSession(); Session session = openSession();
session.beginTransaction(); session.beginTransaction();
@ -79,12 +82,14 @@ public class SimpleResultSetProcessorTest extends BaseCoreFunctionalTestCase {
session.close(); session.close();
{ {
final Session workSession = openSession(); final EntityLoadQueryImpl queryBuilder = new EntityLoadQueryImpl(
workSession.beginTransaction(); sessionFactory(),
final EntityPersister entityPersister = sessionFactory().getEntityPersister( SimpleEntity.class.getName() ); LoadQueryInfluencers.NONE,
final EntityLoader loader = (EntityLoader) BatchingEntityLoaderBuilder.getBuilder( sessionFactory() ) LockMode.NONE,
.buildLoader( (OuterJoinLoadable) entityPersister, -1, LockMode.NONE, sessionFactory(), LoadQueryInfluencers.NONE ); (OuterJoinLoadable) entityPersister
final String sql = loader.getSQLString(); );
final String sql = queryBuilder.generateSql( 1 );
final SingleRootReturnLoadPlanBuilderStrategy strategy = new SingleRootReturnLoadPlanBuilderStrategy( final SingleRootReturnLoadPlanBuilderStrategy strategy = new SingleRootReturnLoadPlanBuilderStrategy(
sessionFactory(), sessionFactory(),
LoadQueryInfluencers.NONE, LoadQueryInfluencers.NONE,
@ -94,6 +99,9 @@ public class SimpleResultSetProcessorTest extends BaseCoreFunctionalTestCase {
final LoadPlan plan = LoadPlanBuilder.buildRootEntityLoadPlan( strategy, entityPersister ); final LoadPlan plan = LoadPlanBuilder.buildRootEntityLoadPlan( strategy, entityPersister );
final ResultSetProcessorImpl resultSetProcessor = new ResultSetProcessorImpl( plan ); final ResultSetProcessorImpl resultSetProcessor = new ResultSetProcessorImpl( plan );
final List results = new ArrayList(); final List results = new ArrayList();
final Session workSession = openSession();
workSession.beginTransaction();
workSession.doWork( workSession.doWork(
new Work() { new Work() {
@Override @Override