Hibernate version: 3.3.1GA
Hibernate Search 3.1.0GA
Lucene 2.4.0
Hallo,
we have a abstract class a with annotation like this
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Indexed
this class is annotate as a single_table, we got this exception:
Cannot mix criteria and multiple entity types
and this change was happend after HSEARCH-160.
We have make a quick fix for this, it's not nice, maybe you can fix it in the next version
Code:
public class SearchFactoryImpl implements SearchFactoryImplementor {
...
private void initDocumentBuilders(SearchConfiguration cfg, ReflectionManager reflectionManager) {
...
//if ( mappedXClass.isAbstract() ) {
// log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
// continue;
//}
...
}
...
Set<Class<?>> getIndexedClasses(Class<?>[] classes) {
Set<Class<?>> idexedClasses = new HashSet<Class<?>>();
for ( Class clazz : classes ) {
Inheritance inheritance = (Inheritance) clazz.getAnnotation(Inheritance.class);
if(inheritance!=null && inheritance.strategy().equals(InheritanceType.SINGLE_TABLE))
{
idexedClasses.add(clazz);
}
else
{
Set<Class<?>> set = classToIndexedClass.get( clazz );
if ( set != null ) {
// at this point we don't have to care about including indexed subclasses of a indexed class
// MultiClassesQueryLoader will take care of this later and optimise the queries
idexedClasses.addAll( set );
}
}
}
if ( log.isTraceEnabled() ) {
log.trace( "Targeted indexed classes for {}: {}", Arrays.toString( classes ), idexedClasses );
}
return idexedClasses;
}
...
}