[hibernate-commits] Hibernate SVN: r19162 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Apr 2 13:02:49 EDT 2010
Author: epbernard
Date: 2010-04-02 13:02:49 -0400 (Fri, 02 Apr 2010)
New Revision: 19162
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java
Log:
HSEARCH-489 remove code handling Restriction.in usage in case of composite id as Core 3.5 does it now
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2010-04-02 15:24:51 UTC (rev 19161)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java 2010-04-02 17:02:49 UTC (rev 19162)
@@ -132,10 +132,6 @@
*/
private boolean idProvided = false;
-
- //if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
- private boolean safeFromTupleId;
-
/**
* Creates a document builder for entities annotated with <code>@Indexed</code>.
*
@@ -169,10 +165,6 @@
throw new SearchException( "No document id in: " + clazz.getName() );
}
- //if composite id, use of (a, b) in ((1,2),(3,4)) fails on most database
- //a TwoWayString2FieldBridgeAdaptor is never a composite id
- safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom( idBridge.getClass() );
-
checkAllowFieldSelection();
if ( log.isDebugEnabled() ) {
log.debug(
@@ -567,13 +559,6 @@
return allowFieldSelectionInProjection;
}
- /**
- * @return <code>false</code> if there is a risk of composite id. If composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
- */
- public boolean isSafeFromTupleId() {
- return safeFromTupleId;
- }
-
public Term getTerm(Serializable id) {
if ( idProvided ) {
return new Term( idKeywordName, ( String ) id );
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java 2010-04-02 15:24:51 UTC (rev 19161)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/ObjectLoaderHelper.java 2010-04-02 17:02:49 UTC (rev 19162)
@@ -73,31 +73,22 @@
Set<Class<?>> indexedEntities = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class<?>[]{entityType} );
DocumentBuilderIndexedEntity<?> builder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( indexedEntities.iterator().next() );
- //FIXME starting from Core 3.5, this loging is handled in Restrictions.in so we should remove this code.
- boolean useInClause = builder.isSafeFromTupleId();
String idName = builder.getIdentifierName();
-
Disjunction disjunction = Restrictions.disjunction();
- if (useInClause) {
- int loop = maxResults / MAX_IN_CLAUSE;
- boolean exact = maxResults % MAX_IN_CLAUSE == 0;
- if ( !exact ) loop++;
- for (int index = 0; index < loop; index++) {
- int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
- index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
- maxResults;
- List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
- for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
- ids.add( entityInfos[entityInfoIndex].id );
- }
- disjunction.add( Restrictions.in( idName, ids ) );
+
+ int loop = maxResults / MAX_IN_CLAUSE;
+ boolean exact = maxResults % MAX_IN_CLAUSE == 0;
+ if ( !exact ) loop++;
+ for (int index = 0; index < loop; index++) {
+ int max = index * MAX_IN_CLAUSE + MAX_IN_CLAUSE <= maxResults ?
+ index * MAX_IN_CLAUSE + MAX_IN_CLAUSE :
+ maxResults;
+ List<Serializable> ids = new ArrayList<Serializable>( max - index * MAX_IN_CLAUSE );
+ for (int entityInfoIndex = index * MAX_IN_CLAUSE; entityInfoIndex < max; entityInfoIndex++) {
+ ids.add( entityInfos[entityInfoIndex].id );
}
+ disjunction.add( Restrictions.in( idName, ids ) );
}
- else {
- for (EntityInfo entityInfo : entityInfos) {
- disjunction.add( Restrictions.eq( idName, entityInfo.id ) );
- }
- }
criteria.add( disjunction );
criteria.list(); //load all objects
}
More information about the hibernate-commits
mailing list