[hibernate-commits] Hibernate SVN: r17851 - in search/trunk/src: main/java/org/hibernate/search/backend and 5 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Oct 27 15:27:03 EDT 2009


Author: sannegrinovero
Date: 2009-10-27 15:27:02 -0400 (Tue, 27 Oct 2009)
New Revision: 17851

Added:
   search/trunk/src/test/java/org/hibernate/search/test/similarity/IllegalSimilarityConfigurationTest.java
   search/trunk/src/test/java/org/hibernate/search/test/similarity/LittleTrash.java
   search/trunk/src/test/java/org/hibernate/search/test/similarity/ProperTrashExtension.java
   search/trunk/src/test/java/org/hibernate/search/test/similarity/Sink.java
   search/trunk/src/test/java/org/hibernate/search/test/similarity/SmallerCan.java
Modified:
   search/trunk/src/main/docbook/en-US/modules/lucene-native.xml
   search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java
   search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java
   search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
   search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
   search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
   search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java
   search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java
Log:
HSEARCH-367 - Support only one kind of Similarity per index

Modified: search/trunk/src/main/docbook/en-US/modules/lucene-native.xml
===================================================================
--- search/trunk/src/main/docbook/en-US/modules/lucene-native.xml	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/docbook/en-US/modules/lucene-native.xml	2009-10-27 19:27:02 UTC (rev 17851)
@@ -210,5 +210,11 @@
     should be scored the same as documents with multiple occurrences. In this
     case your custom implementation of the method <methodname>tf(float
     freq)</methodname> should return 1.0.</para>
+    
+    <warning><para>When two entities share the same index they must declare the
+    same <classname>Similarity</classname> implementation. Classes in the same
+    class hierarchy always share the index, so it's not allowed to override the
+    <classname>Similarity</classname> implementation in a subtype.</para></warning>
+    
   </section>
 </chapter>

Modified: search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/java/org/hibernate/search/backend/Workspace.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -32,6 +32,7 @@
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.Similarity;
 import org.slf4j.Logger;
 
 import org.hibernate.search.SearchException;
@@ -67,6 +68,7 @@
 	private final ReentrantLock lock;
 	private final Set<Class<?>> entitiesInDirectory;
 	private final LuceneIndexingParameters indexingParams;
+	private final Similarity similarity;
 
 	// variable state:
 	
@@ -87,6 +89,7 @@
 		this.entitiesInDirectory = searchFactoryImplementor.getClassesInDirectoryProvider( provider );
 		this.indexingParams = searchFactoryImplementor.getIndexingParameters( directoryProvider );
 		this.lock = searchFactoryImplementor.getDirectoryProviderLock( provider );
+		this.similarity = searchFactoryImplementor.getSimilarity( directoryProvider );
 	}
 
 	public <T> DocumentBuilderIndexedEntity<T> getDocumentBuilder(Class<T> entity) {
@@ -126,7 +129,7 @@
 		lock.lock();
 		try {
 			//Needs to ensure the optimizerStrategy is accessed in threadsafe way
-			synchronized (optimizerStrategy) {
+			synchronized ( optimizerStrategy ) {
 				optimizerStrategy.optimizationForced();
 			}
 		}
@@ -148,6 +151,7 @@
 		try {
 			writer = new IndexWriter( directoryProvider.getDirectory(), SIMPLE_ANALYZER, false, maxFieldLength ); // has been created at init time
 			indexingParams.applyToWriter( writer, batchmode );
+			writer.setSimilarity( similarity );
 			log.trace( "IndexWriter opened" );
 		}
 		catch ( IOException e ) {

Modified: search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/works/AddWorkDelegate.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -29,7 +29,6 @@
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.search.Similarity;
 import org.slf4j.Logger;
 
 import org.hibernate.search.SearchException;
@@ -42,7 +41,7 @@
 import org.hibernate.search.util.ScopedAnalyzer;
 
 /**
- * Stateless implementation that performs a <code>AddLuceneWork</code>.
+ * Stateless implementation that performs an <code>AddLuceneWork</code>.
  *
  * @author Emmanuel Bernard
  * @author Hardy Ferentschik
@@ -67,8 +66,7 @@
 		DocumentBuilderIndexedEntity documentBuilder = workspace.getDocumentBuilder( entityType );
 		Map<String, String> fieldToAnalyzerMap = ( ( AddLuceneWork ) work ).getFieldToAnalyzerMap();
 		ScopedAnalyzer analyzer = ( ScopedAnalyzer ) documentBuilder.getAnalyzer();
-		analyzer = updateAnalyzerMappings( analyzer, fieldToAnalyzerMap, workspace );
-		Similarity similarity = documentBuilder.getSimilarity();
+		analyzer = updateAnalyzerMappings( analyzer, fieldToAnalyzerMap );
 		if ( log.isTraceEnabled() ) {
 			log.trace(
 					"add to Lucene index: {}#{}:{}",
@@ -76,9 +74,6 @@
 			);
 		}
 		try {
-			//TODO the next two operations should be atomic to enable concurrent usage of IndexWriter
-			// make a wrapping Similarity based on ThreadLocals? or have it autoselect implementation basing on entity?
-			writer.setSimilarity( similarity );
 			writer.addDocument( work.getDocument(), analyzer );
 			workspace.incrementModificationCounter( 1 );
 		}
@@ -95,14 +90,13 @@
 	 *
 	 * @param scopedAnalyzer The scoped analyzer created at startup time.
 	 * @param fieldToAnalyzerMap A map of <code>Document</code> field names for analyzer names. This map gets creates
-	 * when the Lucene <code>Document</code> gets created and uses the state of the entiy to index to determine analyzers
+	 * when the Lucene <code>Document</code> gets created and uses the state of the entity to index to determine analyzers
 	 * dynamically at index time.
-	 * @param workspace The current workspace.
 	 * @return <code>scopedAnalyzer</code> in case <code>fieldToAnalyzerMap</code> is <code>null</code> or empty. Otherwise
 	 * a clone of <code>scopedAnalyzer</code> is created where the analyzers get overriden according to <code>fieldToAnalyzerMap</code>.
 	 */
-	private ScopedAnalyzer updateAnalyzerMappings(ScopedAnalyzer scopedAnalyzer, Map<String, String> fieldToAnalyzerMap, Workspace workspace) {
-		// for backwards compatability
+	private ScopedAnalyzer updateAnalyzerMappings(ScopedAnalyzer scopedAnalyzer, Map<String, String> fieldToAnalyzerMap) {
+		// for backwards compatibility
 		if ( fieldToAnalyzerMap == null || fieldToAnalyzerMap.isEmpty() ) {
 			return scopedAnalyzer;
 		}

Modified: search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -93,7 +93,7 @@
 	protected int level = 0;
 	protected int maxLevel = Integer.MAX_VALUE;
 	protected final ScopedAnalyzer analyzer = new ScopedAnalyzer();
-	protected Similarity similarity;
+	protected Similarity similarity; //there is only 1 similarity per class hierarchy, and only 1 per index
 	protected boolean isRoot;
 	protected EntityState entityState;
 
@@ -214,7 +214,6 @@
 		checkForAnalyzerDiscriminator( clazz, propertiesMetadata );
 
 		// Get similarity
-		//TODO: similarity form @IndexedEmbedded are not taken care of. Exception??
 		if ( isRoot ) {
 			checkForSimilarity( clazz );
 		}
@@ -585,7 +584,7 @@
 		}
 	}
 
-	protected Float getBoost(XClass element) {
+	protected float getBoost(XClass element) {
 		float boost = 1.0f;
 		if ( element == null ) {
 			return boost;
@@ -631,7 +630,7 @@
 	}
 
 	/**
-	 * If we have a work instance we have to check whether the intance to be indexed is contained in any other indexed entities.
+	 * If we have a work instance we have to check whether the instance to be indexed is contained in any other indexed entities.
 	 *
 	 * @param instance The instance to be indexed
 	 * @param queue the current work queue

Modified: search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -28,6 +28,7 @@
 import java.util.Set;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.lucene.search.Similarity;
 import org.hibernate.search.SearchFactory;
 import org.hibernate.search.backend.BackendQueueProcessorFactory;
 import org.hibernate.search.backend.LuceneIndexingParameters;
@@ -88,4 +89,6 @@
 	Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes);
 	
 	BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor);
+
+	Similarity getSimilarity(DirectoryProvider<?> directoryProvider);
 }

Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -40,6 +40,7 @@
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.search.Similarity;
 import org.slf4j.Logger;
 
 import org.hibernate.annotations.common.reflection.ReflectionManager;
@@ -159,6 +160,7 @@
 		for ( DocumentBuilderContainedEntity builder : documentBuildersContainedEntities.values() ) {
 			builder.postInitialize( indexedClasses );
 		}
+		fillSimilarityMapping();
 		this.worker = WorkerFactory.createWorker( cfg, this );
 		this.readerProvider = ReaderProviderFactory.createReaderProvider( cfg, this );
 		this.filterCachingStrategy = buildFilterCachingStrategy( cfg.getProperties() );
@@ -169,6 +171,24 @@
 		this.barrier = 1; //write barrier
 	}
 
+	private void fillSimilarityMapping() {
+		for ( DirectoryProviderData directoryConfiguration : dirProviderData.values() ) {
+			for (Class<?> indexedType : directoryConfiguration.classes) {
+				DocumentBuilderIndexedEntity<?> documentBuilder = documentBuildersIndexedEntities.get( indexedType );
+				Similarity similarity = documentBuilder.getSimilarity();
+				Similarity prevSimilarity = directoryConfiguration.similarity;
+				if ( prevSimilarity != null && ! prevSimilarity.getClass().equals( similarity.getClass() ) ) {
+					throw new SearchException( "Multiple entities are sharing the same index but are declaring an " + 
+							"inconsistent Similarity. When overrriding default Similarity make sure that all types sharing a same index " +
+							"declare the same Similarity implementation." );
+				}
+				else {
+					directoryConfiguration.similarity = similarity;
+				}
+			}
+		}
+	}
+
 	private ReflectionManager getReflectionManager(SearchConfiguration cfg) {
 		ReflectionManager reflectionManager = cfg.getReflectionManager();
 		if ( reflectionManager == null ) {
@@ -421,7 +441,7 @@
 		return analyzer;
 	}
 
-	public Analyzer getAnalyzer(Class clazz) {
+	public Analyzer getAnalyzer(Class<?> clazz) {
 		if ( clazz == null ) {
 			throw new IllegalArgumentException( "A class has to be specified for retrieving a scoped analyzer" );
 		}
@@ -534,7 +554,8 @@
 	private static class DirectoryProviderData {
 		public final ReentrantLock dirLock = new ReentrantLock();
 		public OptimizerStrategy optimizerStrategy;
-		public Set<Class<?>> classes = new HashSet<Class<?>>( 2 );
+		public final Set<Class<?>> classes = new HashSet<Class<?>>( 2 );
+		public Similarity similarity = null;
 	}
 
 	public ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp) {
@@ -623,4 +644,13 @@
 			return idexedClasses;
 		}
 	}
+
+	public Similarity getSimilarity(DirectoryProvider<?> provider) {
+		if ( barrier != 0 ) {
+		} //read barrier
+		Similarity similarity = dirProviderData.get( provider ).similarity;
+		if ( similarity == null ) throw new SearchException( "Assertion error: a similarity should be defined for each provider" );
+		return similarity;
+	}
+
 }

Added: search/trunk/src/test/java/org/hibernate/search/test/similarity/IllegalSimilarityConfigurationTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/IllegalSimilarityConfigurationTest.java	                        (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/IllegalSimilarityConfigurationTest.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -0,0 +1,102 @@
+/* $Id$
+ * 
+ * Hibernate, Relational Persistence for Idiomatic Java
+ * 
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ * 
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.search.test.similarity;
+
+import junit.framework.TestCase;
+
+import org.hibernate.search.test.util.FullTextSessionBuilder;
+
+public class IllegalSimilarityConfigurationTest extends TestCase {
+
+	public void testValidConfiguration() {
+		boolean configurationIsLegal = true;
+		try {
+			FullTextSessionBuilder builder = new FullTextSessionBuilder()
+					.addAnnotatedClass(Can.class)
+					.addAnnotatedClass(Trash.class).build();
+			builder.close();
+		} catch (Exception e) {
+			configurationIsLegal = false;
+		}
+		assertTrue( "A valid configuration could not be started.", configurationIsLegal );
+	}
+	
+	public void testInconsistentSimilarityInClassHierarchy() {
+		boolean configurationIsLegal = true;
+		try {
+			FullTextSessionBuilder builder = new FullTextSessionBuilder()
+					.addAnnotatedClass( Trash.class )
+					.addAnnotatedClass( LittleTrash.class ).build();
+			builder.close();
+		} catch (Exception e) {
+			configurationIsLegal = false;
+		}
+		assertFalse( "Invalid Similarity declared, should have thrown an exception: same similarity"
+				+ " must be used across class hierarchy", configurationIsLegal );
+	}
+	
+	public void testInconsistentSimilarityInClassSharingAnIndex() {
+		boolean configurationIsLegal = true;
+		try {
+			FullTextSessionBuilder builder = new FullTextSessionBuilder()
+					.addAnnotatedClass( Trash.class )
+					.addAnnotatedClass( Sink.class ).build();
+			builder.close();
+		} catch (Exception e) {
+			configurationIsLegal = false;
+		}
+		assertFalse( "Invalid Similarity declared, should have thrown an exception: two entities"
+				+ "sharing the same index are using a different similarity", configurationIsLegal );
+}
+	
+	public void testImplicitSimilarityInheritanceIsValid() {
+		boolean configurationIsLegal = true;
+		try {
+			FullTextSessionBuilder builder = new FullTextSessionBuilder()
+					.addAnnotatedClass( Trash.class )
+					.addAnnotatedClass( ProperTrashExtension.class ).build();
+			builder.close();
+		} catch (Exception e) {
+			configurationIsLegal = false;
+		}
+		assertTrue( "Valid configuration could not be built", configurationIsLegal );
+}
+	
+	public void testInvalidToOverrideParentsSimilarity() {
+		boolean configurationIsLegal = true;
+		try {
+			FullTextSessionBuilder builder = new FullTextSessionBuilder()
+					.addAnnotatedClass( Can.class )
+					.addAnnotatedClass( SmallerCan.class ).build();
+			builder.close();
+		} catch (Exception e) {
+			configurationIsLegal = false;
+		}
+		assertFalse( "Invalid Similarity declared, should have thrown an exception: child entity"
+				+ " is overriding parent's Similarity", configurationIsLegal );
+	}
+
+}
+


Property changes on: search/trunk/src/test/java/org/hibernate/search/test/similarity/IllegalSimilarityConfigurationTest.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Added: search/trunk/src/test/java/org/hibernate/search/test/similarity/LittleTrash.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/LittleTrash.java	                        (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/LittleTrash.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -0,0 +1,41 @@
+/* $Id$
+ * 
+ * Hibernate, Relational Persistence for Idiomatic Java
+ * 
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ * 
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.search.test.similarity;
+
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Similarity;
+
+/**
+ * @author Sanne Grinovero
+ */
+ at Entity
+ at Similarity(impl = DummySimilarity2.class)
+public class LittleTrash extends Trash {
+	
+	//extends Trash, but declares a different similarity
+
+}
+


Property changes on: search/trunk/src/test/java/org/hibernate/search/test/similarity/LittleTrash.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Added: search/trunk/src/test/java/org/hibernate/search/test/similarity/ProperTrashExtension.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/ProperTrashExtension.java	                        (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/ProperTrashExtension.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -0,0 +1,36 @@
+/* $Id$
+ * 
+ * Hibernate, Relational Persistence for Idiomatic Java
+ * 
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ * 
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.search.test.similarity;
+
+import org.hibernate.search.annotations.Indexed;
+
+ at Indexed
+//Is inheriting: @Similarity(impl = DummySimilarity.class)
+public class ProperTrashExtension extends Trash {
+	
+	//only needing a different type for testing purposes
+
+}
+


Property changes on: search/trunk/src/test/java/org/hibernate/search/test/similarity/ProperTrashExtension.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Added: search/trunk/src/test/java/org/hibernate/search/test/similarity/Sink.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/Sink.java	                        (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/Sink.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -0,0 +1,67 @@
+/* $Id$
+ * 
+ * Hibernate, Relational Persistence for Idiomatic Java
+ * 
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ * 
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.search.test.similarity;
+
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Similarity;
+
+/**
+ * @author Sanne Grinovero
+ */
+ at Entity
+ at Indexed(index="garbageIndex")
+ at Similarity(impl = DummySimilarity2.class)
+public class Sink {
+	@Id
+	@DocumentId
+	@GeneratedValue
+	private Integer id;
+	
+	@Field
+	private String name;
+
+	public Integer getId() {
+		return id;
+	}
+
+	public void setId(Integer id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+}
+


Property changes on: search/trunk/src/test/java/org/hibernate/search/test/similarity/Sink.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Added: search/trunk/src/test/java/org/hibernate/search/test/similarity/SmallerCan.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/SmallerCan.java	                        (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/SmallerCan.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -0,0 +1,40 @@
+/* $Id$
+ * 
+ * Hibernate, Relational Persistence for Idiomatic Java
+ * 
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ * 
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.search.test.similarity;
+
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.Similarity;
+
+ at Entity
+ at Indexed
+ at Similarity(impl = DummySimilarity2.class)
+public class SmallerCan extends Can {
+
+	//illegal type: can't override a parent defined Similarity
+	
+}
+


Property changes on: search/trunk/src/test/java/org/hibernate/search/test/similarity/SmallerCan.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + LF

Modified: search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/test/java/org/hibernate/search/test/similarity/Trash.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -37,7 +37,7 @@
  * @author Emmanuel Bernard
  */
 @Entity
- at Indexed
+ at Indexed(index="garbageIndex")
 @Similarity(impl = DummySimilarity.class)
 public class Trash {
 	@Id

Modified: search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java	2009-10-27 18:49:25 UTC (rev 17850)
+++ search/trunk/src/test/java/org/hibernate/search/test/util/FullTextSessionBuilder.java	2009-10-27 19:27:02 UTC (rev 17851)
@@ -50,7 +50,7 @@
 	
 	private static final Logger log = org.hibernate.search.util.LoggerFactory.make();
 
-	private static File indexDir;
+	private static final File indexDir;
 
 	private AnnotationConfiguration cfg;
 	private SessionFactory sessionFactory;



More information about the hibernate-commits mailing list