1 Reply Latest reply on Mar 10, 2015 5:48 AM by Tobias Herrmann

    Problem when querying to different entity types

    Tobias Herrmann Newbie

      I want to use two infinispan caches with different object types stored in them. Storing the objects and accessing them through their keys works fine. But when using the query DSL to find specific object in the caches my code fails with an

       

      java.lang.IllegalStateException: Unknown entity name org.project.Relation

       

      exception.

       

      I run the following code to setup my caches:

       

      DefaultCacheManager manager = new DefaultCacheManager("infinispan.xml");

       

      Cache<String, Resource> resourceCache = manager.getCache("Resources");

      QueryFactory<LuceneQuery> resourceQueryFactory = Search.getQueryFactory(resourceCache);

       

      Cache<String, Relation> relationCache = manager.getCache("Relations");

      QueryFactory<LuceneQuery>relationQueryFactory = Search.getQueryFactory(relationCache);

       

      When using the query DSL to search the resources cache first and then the relations cache I get the following stack trace:

       

      java.lang.IllegalStateException: Unknown entity name org.project.Relation

        at org.hibernate.hql.lucene.internal.ClassBasedLuceneQueryResolverDelegate.registerPersisterSpace(ClassBasedLuceneQueryResolverDelegate.java:104)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.entityName(GeneratedHQLResolver.java:12729)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.persisterSpaceRoot(GeneratedHQLResolver.java:3064)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.persisterSpace(GeneratedHQLResolver.java:2956)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.persisterSpaces(GeneratedHQLResolver.java:2893)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.fromClause(GeneratedHQLResolver.java:2803)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.selectFrom(GeneratedHQLResolver.java:2704)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.querySpec(GeneratedHQLResolver.java:2182)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryExpression(GeneratedHQLResolver.java:2106)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryStatement(GeneratedHQLResolver.java:1745)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.queryStatementSet(GeneratedHQLResolver.java:1658)

        at org.hibernate.hql.ast.origin.hql.resolve.GeneratedHQLResolver.statement(GeneratedHQLResolver.java:654)

        at org.hibernate.hql.ast.spi.QueryResolverProcessor.process(QueryResolverProcessor.java:52)

        at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:82)

        at org.infinispan.query.dsl.embedded.impl.EmbeddedLuceneQueryBuilder.parse(EmbeddedLuceneQueryBuilder.java:66)

        at org.infinispan.query.dsl.embedded.impl.EmbeddedLuceneQueryBuilder.build(EmbeddedLuceneQueryBuilder.java:52)

        at org.infinispan.query.dsl.embedded.impl.EmbeddedLuceneQueryBuilder.build(EmbeddedLuceneQueryBuilder.java:20)

        at org.project.Test.main(Test.java:42)

       

      Running a test where only one of the caches is searched works fine. So I assume this is not caused by the specific query or the type of objects I store in the cache, but by trying to search for two different types.

       

      I am using Infinispan 7.1.1 with the following configuration:

       

      <infinispan>

        <cache-container default-cache="default"  statistics="true" name="Repository">

        <local-cache name="default"  statistics="true">

        <transaction

        transaction-manager-lookup="org.infinispan.transaction.lookup.DummyTransactionManagerLookup"

        mode="NON_XA" locking="OPTIMISTIC" />

        <indexing index="LOCAL">

        <property name="default.directory_provider">ram</property>

      </indexing>

        </local-cache>

        </cache-container>

      </infinispan>

       

      What am I doing wrong here? Is there anything I need to configure?

       

      Thanks in advance, Tobias