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)
@@ -0,0 +1,17 @@
+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 {@link
org.hibernate.search.annotations.DocumentId} annotated fields.
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+@Retention( RetentionPolicy.RUNTIME )
+@Target( ElementType.TYPE )
+@Documented
+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)
@@ -28,17 +28,7 @@
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;
@@ -108,7 +98,13 @@
//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
Show replies by date