[infinispan-issues] [JBoss JIRA] (ISPN-5710) Unknown entity name when indexing entities defined in inner classes

Gustavo Fernandes (JIRA) issues at jboss.org
Fri Aug 28 09:09:05 EDT 2015


Gustavo Fernandes created ISPN-5710:
---------------------------------------

             Summary: Unknown entity name when indexing entities defined in inner classes
                 Key: ISPN-5710
                 URL: https://issues.jboss.org/browse/ISPN-5710
             Project: Infinispan
          Issue Type: Bug
          Components: Embedded Querying
    Affects Versions: 8.0.0.CR1
            Reporter: Gustavo Fernandes


{code}
import java.util.List;

import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.Index;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.query.Search;
import org.infinispan.query.dsl.Query;
import org.infinispan.query.dsl.QueryFactory;

public class Test {

   public static void main(String[] args) {
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.indexing().index(Index.ALL)
              .addProperty("default.directory_provider", "ram")
              .addProperty("lucene_version", "LUCENE_CURRENT");
      // Construct a simple local cache manager with default configuration
      DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
      // Obtain the default cache
      Cache<String, Person> cache = cacheManager.getCache();
      // Store some entries
      cache.put("person1", new Person("William", "Shakespeare"));
      cache.put("person2", new Person("William", "Wordsworth"));
      cache.put("person3", new Person("John", "Milton"));
      // Obtain a query factory for the cache
      QueryFactory<?> queryFactory = Search.getQueryFactory(cache);
      // Construct a query
      Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build();
      // Execute the query
      List<Person> matches = query.list();
      matches.forEach(person -> System.out.printf("Match: %s", person));
      // Stop the cache manager and release all resources
      cacheManager.stop();
   }

   @Indexed
    static class Person {
      @Field(store = Store.YES, analyze = Analyze.NO)
      String name;

      @Field(store = Store.YES, analyze = Analyze.NO, indexNullAs = Field.DEFAULT_NULL_TOKEN)
      String surname;

      public Person(String name, String surname) {
         this.name = name;
         this.surname = surname;
      }

      @Override
      public String toString() {
         return "Person2 [name=" + name + ", surname=" + surname + "]";
      }
   }

}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the infinispan-issues mailing list