Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

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

hibernate-commits

2008-06-30


Author LoginPost Reply
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)
@@(protected) @@
 <!-- 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)
@@(protected) @@
               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)
@@(protected) @@
  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()
  {
@@(protected) @@
      {
        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)
@@(protected) @@

    }
    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);
@@(protected) @@
      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;
@@(protected) @@

  public Term getTerm(Serializable id)
  {
+    if (idProvided)
+    {
+      return new Term(idKeywordName, (String) id);
+    }
    return new Term(idKeywordName, idBridge.objectToString(id));
  }

@@(protected) @@
  {
    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)

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.