-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Hibernate Search 3.1.0GA Bugs after HSEARCH-160
PostPosted: Fri Apr 03, 2009 9:42 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
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;
      }
...
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 4:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

could you post also the full stack trace? Or even better create a new Jira issue, adding the stacktrace and maybe a patch for the changes you applied?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 5:40 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
After thinking a little more about this. There is actually a reason why you are not supposedto index abstract classes - http://opensource.atlassian.com/project ... SEARCH-265 . I think what confused me was the error message you got. I would have expected a warning meesage in the log.

It would help if you post yout mapping files and the full stacktrace. Either in this thread or in a new Jira issue.

Have you tried placing the @Indexed annotation on your subclasses?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 6:09 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
hardy.ferentschik wrote:
Hi,

could you post also the full stack trace? Or even better create a new Jira issue, adding the stacktrace and maybe a patch for the changes you applied?

--Hardy


Hi, Hardy,

We got this exception:

Code:
org.hibernate.search.SearchException: Cannot mix criteria and multiple entity types
   at org.hibernate.search.query.FullTextQueryImpl.getLoader(FullTextQueryImpl.java:185)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:283)
   at de.xxx.katalog._internal.service.KatalogEintragServiceImpl.sucheIntern(KatalogEintragServiceImpl.java:245)
   at de.xxx.katalog._internal.service.KatalogEintragServiceImpl.suchen(KatalogEintragServiceImpl.java:194)
   at de.xxx.katalog.test.KatalogEintragServiceImplTest.testSuchen(KatalogEintragServiceImplTest.java:221)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
   at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
   at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
   at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
   at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
   at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
   at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
   at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
   at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
   at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
   at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
   at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 6:13 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
This is our abstractclass:

Code:
@Entity
@Table(name = "kat_katalogeintrag")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "DISC", discriminatorType = DiscriminatorType.STRING, length = 5)
@ProtectableName(hierarchy = ProtectableHierarchy.KATALOG, name = "Katalogeintrag")
@Indexed
public abstract class AbstractKatalogEintrag
{
    @Field
    @FieldBridge(impl = StringFSBridge.class)
    @Index(name = "name")
    @SortCriteria
    private StringFS _name;

    @Field
    private String _alternativName;
    /** Suchwort des Eintrages. */

    @Field
    private String _suchwort;

    /** Kurztext des Katalogeintrages. */
    @Field
    private String _kurztext;

.....

}


And this is a example of subclass

Code:
@Entity
@DiscriminatorValue(value = "ART")
@DomainClassName(key = "ArtikelEintragImpl")
@Indexed
public class ArtikelEintragImpl extends AbstractKatalogEintrag
{
  //no any hibernate search annotation
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 6:17 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
if i remove @Indexed of all 9 subclass, i got this exception:

Code:
   java.lang.IllegalArgumentException: None of the specified entity types or any of their subclasses are indexed.
   at org.hibernate.search.query.FullTextQueryImpl.<init>(FullTextQueryImpl.java:110)
   at org.hibernate.search.impl.FullTextSessionImpl.createFullTextQuery(FullTextSessionImpl.java:86)
   at de.xxx.common.service.persistence.DAOImpl.createMultiFieldQuery(DAOImpl.java:443)
   at de.xxx.common.service.persistence.AbstractServiceImpl.createMultiFieldQuery(AbstractServiceImpl.java:71)
   at de.xxx.katalog._internal.service.KatalogEintragServiceImpl.sucheIntern(KatalogEintragServiceImpl.java:244)
   at de.xxx.katalog._internal.service.KatalogEintragServiceImpl.suchen(KatalogEintragServiceImpl.java:194)
   at de.xxx.katalog.test.KatalogEintragServiceImplTest.testSuchen(KatalogEintragServiceImplTest.java:221)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
   at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
   at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
   at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
   at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
   at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
   at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
   at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
   at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
   at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
   at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
   at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 6:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

what I ment was just removing the @Indexed annotation from AbstractKatalogEintrag. Of course you have to keep the @Indexed annotation on the concrete subclasses.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 7:18 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
hardy.ferentschik wrote:
Hi,

what I ment was just removing the @Indexed annotation from AbstractKatalogEintrag. Of course you have to keep the @Indexed annotation on the concrete subclasses.

--Hardy


Hi, Hardy,

if i remove the @Indexed annotation from AbstractKatalogEintrag, i got the same exception:

"Cannot mix criteria and multiple entity types"

the size of targetedEntities in class FullTextQueryImpl is 9


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 7:19 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
hardy.ferentschik wrote:
Hi,

what I ment was just removing the @Indexed annotation from AbstractKatalogEintrag. Of course you have to keep the @Indexed annotation on the concrete subclasses.

--Hardy


Hi, Hardy,

if i remove the @Indexed annotation from AbstractKatalogEintrag, i got the same exception:

"Cannot mix criteria and multiple entity types"

the size of targetedEntities in class FullTextQueryImpl is 9


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 8:46 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Ok, removing the @Indexed from the abstract class is definitely one step forward.

How does actually your query look like? The restriction that you cannot use the criteria API if more than one entity type is returned it not new. See also the online documentation http://www.hibernate.org/hib_docs/searc ... e/#d0e2689
What do you use the criteria for?

Another problem with your patch is that it creates a hard dependency to JPA since you are checking for the @Inheritance annotation.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 9:14 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
Hi, Hardy,

our query is look like this:

Code:
private final List<AbstractKatalogEintrag> sucheIntern(final AbstractSuchkriterium suchkriterium,
            final SuchbaumEintragImpl suchBaumEintragOpt, final Transaction transaction,
            final KatalogEintragsTypDV... eintragsTypen) throws QueryParseException
    {
        assert suchkriterium != null : "Precondition violated: suchkriterium != null"; //$NON-NLS-1$
        assert StringUtils.isNotBlank(suchkriterium.getSuchWertAsString()) : "Precondition violated: StringUtils.isNotBlank(suchkriterium.getSuchWertAsString())"; //$NON-NLS-1$
        assert transaction != null : "Precondition violated: transaction != null"; //$NON-NLS-1$

        Criteria criteria = transaction.getSession().createCriteria(AbstractKatalogEintrag.class);
        criteria.add(Restrictions.eq("_versteckt", Boolean.FALSE));
        criteria = addMandantRestriction(criteria, AbstractKatalogEintrag.class, ProtectableMainImpl.PROTECTABLEMAIN);

        addEintragsTypCriteria(criteria, eintragsTypen);

        if (suchBaumEintragOpt != null)
        {
            List<SuchbaumEintragImpl> gesuchteEintraege = new ArrayList<SuchbaumEintragImpl>();
            addSuchBaumEintragForQuery(gesuchteEintraege, suchBaumEintragOpt);

            List<Long> gesuchteIds = new ArrayList<Long>();
            for (SuchbaumEintragImpl suchbaumeintrag : gesuchteEintraege)
            {
                gesuchteIds.add(suchbaumeintrag.getDBId());
            }

            Criteria subCriteria = criteria.createCriteria("_suchbaumZuordnungListe", Criteria.INNER_JOIN);
            subCriteria.add(Restrictions.in("_dbID", gesuchteIds));
        }

        List<String> felder = new ArrayList<String>();

        if (suchkriterium.getAttributname().isEmpty())
        {
            List<AbstractSuchkriterium> suchkriterien = getSuchkriterien();

            for (AbstractSuchkriterium kriterium : suchkriterien)
            {
                felder.add(kriterium.getAttributname());
            }
        }
        else
        {
            felder.add(suchkriterium.getAttributname());
        }

        criteria.setMaxResults(DAO.MAX_AUSWAHL_RESULT);
        FullTextQuery query = createMultiFieldQuery(suchkriterium.getSuchWertAsString(), felder.toArray(new String[0]), transaction);
        return query.setCriteriaQuery(criteria).list();
    }


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 9:19 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
hardy.ferentschik wrote:
Ok, removing the @Indexed from the abstract class is definitely one step forward.

How does actually your query look like? The restriction that you cannot use the criteria API if more than one entity type is returned it not new. See also the online documentation http://www.hibernate.org/hib_docs/searc ... e/#d0e2689
What do you use the criteria for?

Another problem with your patch is that it creates a hard dependency to JPA since you are checking for the @Inheritance annotation.

--Hardy


Sure, our "quick patch" is not nice. But our Tests not run after we use 3.1.0GA.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 9:37 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Would it be possible for you to take a subset of your (modified) code (runnable) showing the error and post it to JIRA. This is help us track down the problem.
As Hardy said, we can't apply your patch as it does not work for people using orm.xml or even hbm.xml files but we would like to find the bug.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 10:28 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
emmanuel wrote:
Would it be possible for you to take a subset of your (modified) code (runnable) showing the error and post it to JIRA. This is help us track down the problem.
As Hardy said, we can't apply your patch as it does not work for people using orm.xml or even hbm.xml files but we would like to find the bug.


hello, emmanuel,

of couse i would like post a subset of our code, it will take a few time, because i don't know witch codes are importent for you, maybe next week, my colleague will do it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 6:26 am 
Beginner
Beginner

Joined: Fri Aug 22, 2008 5:49 am
Posts: 22
hi,

i have create a jira task for you with our test code. i hope it's helps.

http://opensource.atlassian.com/project ... SEARCH-360

Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.