Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r14830 - in
 search/branches/jboss_cache_integration/src/java/org/hibernate/search:
 engine and 1 other directory.

hibernate-commits

2008-06-30


Author LoginPost Reply
Author: navssurtani
Date: 2008-06-30 13:14:47 -0400 (Mon, 30 Jun 2008)
New Revision: 14830

Added:
 search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java
Modified:
 search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
Wrote up @ProvidedId

Added: search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java                  (rev 0)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java  2008-06-30 17:14:47 UTC (rev 14830)
@@(protected) @@
+package org.hibernate.search.annotations;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation means that document ids will be generated externally and does not need to be
+ * contained within the class being indexed.
+ * <p />
+ * Basically, this means that classes annotated with this will NOT be scanned for {@(protected).
+ * @author Navin Surtani - navin@(protected)
+ */
+@(protected) )
+@(protected) )
+@(protected)
+public @interface ProvidedId
+{
+}

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:05:11 UTC (rev 14829)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java  2008-06-30 17:14:47 UTC (rev 14830)
@@(protected) @@
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.search.SearchException;
import org.hibernate.search.impl.InitContext;
-import org.hibernate.search.annotations.Boost;
-import org.hibernate.search.annotations.ClassBridge;
-import org.hibernate.search.annotations.ClassBridges;
-import org.hibernate.search.annotations.ContainedIn;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.IndexedEmbedded;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.search.annotations.TermVector;
-import org.hibernate.search.annotations.AnalyzerDefs;
-import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.*;
import org.hibernate.search.backend.AddLuceneWork;
import org.hibernate.search.backend.DeleteLuceneWork;
import org.hibernate.search.backend.LuceneWork;
@@(protected) @@
   //processedClasses.remove( clazz ); for the sake of completness
   this.analyzer.setGlobalAnalyzer( rootPropertiesMetadata.analyzer );
   if ( idKeywordName == null ) {
-      throw new SearchException( "No document id in: " + clazz.getName() );
+      // if no DocumentId then check if we have a ProvidedId instead
+      if (clazz.getAnnotation(ProvidedId.class) == null) {
+        throw new SearchException( "No document id in: " + clazz.getName() );        
+      }
+//      else {
+//        // DON'T throw an exception. This is OK.
+//      }
   }
   //if composite id, use of (a, b) in ((1,2)TwoWayString2FieldBridgeAdaptor, (3,4)) fails on most database
   //a TwoWayString2FieldBridgeAdaptor is never a composite id

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