[hibernate-commits] Hibernate SVN: r14832 - in search/branches/jboss_cache_integration: src/java/org/hibernate/search/backend/impl and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Mon Jun 30 15:22:31 EDT 2008


Author: navssurtani
Date: 2008-06-30 15:22:31 -0400 (Mon, 30 Jun 2008)
New Revision: 14832

Modified:
   search/branches/jboss_cache_integration/build.xml
   search/branches/jboss_cache_integration/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
   search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:


Modified: search/branches/jboss_cache_integration/build.xml
===================================================================
--- search/branches/jboss_cache_integration/build.xml	2008-06-30 17:25:51 UTC (rev 14831)
+++ search/branches/jboss_cache_integration/build.xml	2008-06-30 19:22:31 UTC (rev 14832)
@@ -17,7 +17,7 @@
 	<!-- Name of project and version, used to create filenames -->
 	<property name="Name" value="Hibernate Search"/>
 	<property name="name" value="hibernate-search"/>
-	<property name="version" value="3.1.0-SNAPSHOT"/>
+	<property name="version" value="3.1.1-SNAPSHOT"/>
 	<property name="javadoc.packagenames" value="org.hibernate.search.*"/>
 	<property name="copy.test" value="true"/>
 	<property name="copy.test" value="true"/>

Modified: search/branches/jboss_cache_integration/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java	2008-06-30 17:25:51 UTC (rev 14831)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/backend/impl/BatchedQueueingProcessor.java	2008-06-30 19:22:31 UTC (rev 14832)
@@ -138,7 +138,7 @@
 								Hibernate.getClass( work.getEntity() );
 					DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( entityClass );
 					if ( builder == null ) continue; //or exception?
-					builder.addWorkToQueue(entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor );
+               builder.addWorkToQueue(entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor );
 				}
 			}
 		}

Modified: search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java	2008-06-30 17:25:51 UTC (rev 14831)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java	2008-06-30 19:22:31 UTC (rev 14832)
@@ -76,6 +76,7 @@
    private boolean isRoot;
    //if composite id, use of (a, b) in ((1,2), (3,4)) fails on most database
    private boolean safeFromTupleId;
+   private boolean idProvided = false;
 
    public boolean isRoot()
    {
@@ -107,13 +108,21 @@
          {
             throw new SearchException("No document id in: " + clazz.getName());
          }
-//         else {
-//            // DON'T throw an exception.  This is OK.
-//         }
+         else
+         {
+            // DON'T throw an exception.  This is OK.
+            idProvided = true;
+            idKeywordName = "ThisIsAProvidedId";
+         }
       }
-      //if composite id, use of (a, b) in ((1,2)TwoWayString2FieldBridgeAdaptor, (3,4)) fails on most database
-      //a TwoWayString2FieldBridgeAdaptor is never a composite id
-      safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom(idBridge.getClass());
+      else
+      {
+         // this stuff only happens when a DocumentId is used.
+
+         //if composite id, use of (a, b) in ((1,2)TwoWayString2FieldBridgeAdaptor, (3,4)) fails on most database
+         //a TwoWayString2FieldBridgeAdaptor is never a composite id
+         safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom(idBridge.getClass());
+      }
    }
 
    private Analyzer getAnalyzer(XAnnotatedElement annotatedElement, InitContext context)
@@ -568,7 +577,8 @@
 
       }
       boolean searchForContainers = false;
-      String idInString = idBridge.objectToString(id);
+      // if the ID is provided for this type, then just directly cast the id to a String.
+      String idInString = idProvided ? (String) id : idBridge.objectToString(id);
       if (workType == WorkType.ADD)
       {
          Document doc = getDocument(entity, id);
@@ -694,7 +704,7 @@
          Field classField =
                  new Field(CLASS_FIELDNAME, instanceClass.getName(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO);
          doc.add(classField);
-         idBridge.set(idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO, idBoost);
+         if(!idProvided) idBridge.set(idKeywordName, id, doc, Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO, idBoost);
       }
       buildDocumentFields(instance, doc, rootPropertiesMetadata);
       return doc;
@@ -782,6 +792,10 @@
 
    public Term getTerm(Serializable id)
    {
+      if (idProvided)
+      {
+         return new Term(idKeywordName, (String) id);
+      }
       return new Term(idKeywordName, idBridge.objectToString(id));
    }
 
@@ -835,7 +849,7 @@
    {
       DocumentBuilder builder = searchFactoryImplementor.getDocumentBuilders().get(clazz);
       if (builder == null) throw new SearchException("No Lucene configuration set up for: " + clazz.getName());
-      return (Serializable) builder.getIdBridge().get(builder.getIdKeywordName(), document);
+      return (Serializable) builder.getIdBridge().get(builder.getIdKeywordName(), document);      
    }
 
    public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class clazz, Document document, String[] fields)




More information about the hibernate-commits mailing list