[hibernate-commits] Hibernate SVN: r20822 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Oct 13 07:26:45 EDT 2010
Author: epbernard
Date: 2010-10-13 07:26:45 -0400 (Wed, 13 Oct 2010)
New Revision: 20822
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
Log:
HSEARCH-546 Support THIS Projection and fetching definition
Clean up ProjectionLoader after LoaderBuilder refactoring
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2010-10-13 11:26:14 UTC (rev 20821)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ProjectionLoader.java 2010-10-13 11:26:45 UTC (rev 20822)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.hibernate.Session;
import org.hibernate.annotations.common.AssertionFailure;
@@ -40,40 +39,31 @@
* @author Hardy Ferentschik
*/
public class ProjectionLoader implements Loader {
- private SearchFactoryImplementor searchFactoryImplementor;
- private Session session;
private Loader objectLoader;
private Boolean projectThis;
private ResultTransformer transformer;
private String[] aliases;
- private Set<Class<?>> entityTypes;
private ObjectLoaderBuilder loaderBuilder;
public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
- this.session = session;
- this.searchFactoryImplementor = searchFactoryImplementor;
}
public void init(Session session, SearchFactoryImplementor searchFactoryImplementor, ResultTransformer transformer, ObjectLoaderBuilder loaderBuilder, String[] aliases) {
- init( session, searchFactoryImplementor );
+ init(session, searchFactoryImplementor);
this.transformer = transformer;
this.aliases = aliases;
this.loaderBuilder = loaderBuilder;
}
- public void setEntityTypes(Set<Class<?>> entityTypes) {
- this.entityTypes = entityTypes;
- }
-
public Object load(EntityInfo entityInfo) {
- initThisProjectionFlag( entityInfo );
- if ( projectThis ) {
- for ( int index : entityInfo.indexesOfThis ) {
- entityInfo.projection[index] = objectLoader.load( entityInfo );
+ initThisProjectionFlag(entityInfo);
+ if (projectThis) {
+ for (int index : entityInfo.indexesOfThis) {
+ entityInfo.projection[index] = objectLoader.load(entityInfo);
}
}
- if ( transformer != null ) {
- return transformer.transformTuple( entityInfo.projection, aliases );
+ if (transformer != null) {
+ return transformer.transformTuple(entityInfo.projection, aliases);
}
else {
return entityInfo.projection;
@@ -85,37 +75,37 @@
}
private void initThisProjectionFlag(EntityInfo entityInfo) {
- if ( projectThis == null ) {
+ if (projectThis == null) {
projectThis = entityInfo.indexesOfThis.size() != 0;
- if ( projectThis ) {
+ if (projectThis) {
objectLoader = loaderBuilder.buildLoader();
}
}
}
public List load(EntityInfo... entityInfos) {
- List results = new ArrayList( entityInfos.length );
- if ( entityInfos.length == 0 ) {
+ List results = new ArrayList(entityInfos.length);
+ if (entityInfos.length == 0) {
return results;
}
- initThisProjectionFlag( entityInfos[0] );
- if ( projectThis ) {
- objectLoader.load( entityInfos ); // load by batch
- for ( EntityInfo entityInfo : entityInfos ) {
- for ( int index : entityInfo.indexesOfThis ) {
+ initThisProjectionFlag(entityInfos[0]);
+ if (projectThis) {
+ objectLoader.load(entityInfos); // load by batch
+ for (EntityInfo entityInfo : entityInfos) {
+ for (int index : entityInfo.indexesOfThis) {
// set one by one to avoid loosing null objects (skipped in the objectLoader.load( EntityInfo[] ))
// use objectLoader.executeLoad to prevent measuring load time again (see AbstractLoader)
- entityInfo.projection[index] = objectLoader.loadWithoutTiming( entityInfo );
+ entityInfo.projection[index] = objectLoader.loadWithoutTiming(entityInfo);
}
}
}
- for ( EntityInfo entityInfo : entityInfos ) {
- if ( transformer != null ) {
- results.add( transformer.transformTuple( entityInfo.projection, aliases ) );
+ for (EntityInfo entityInfo : entityInfos) {
+ if (transformer != null) {
+ results.add(transformer.transformTuple(entityInfo.projection, aliases));
}
else {
- results.add( entityInfo.projection );
+ results.add(entityInfo.projection);
}
}
More information about the hibernate-commits
mailing list