Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.4.0.Final
    • Component/s: query
    • Labels:
      None
    • Environment:
      Hibernate ORM 4.2.7-SNAPSHOT, Javaassist 3.18.1-GA
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      I just tried upgrading everything to the latest version and I ran into this blocker

      FullTextSession fts = Search.getFullTextSession(getSessionFactory().getCurrentSession());
          
       QueryBuilder qb = fts.getSearchFactory().buildQueryBuilder().forEntity(Usor.class).get();
       
       return (Long) fts.createFullTextQuery(qb.bool()
          .must(
             qb.keyword().onField("site.id").ignoreAnalyzer().matching(countrySite.getSite().getId()).createQuery()
          )
          .must(            
             qb.keyword().onField("location.country.countryCode").ignoreAnalyzer().matching(countrySite.getCountry().getCountryCode()).createQuery()   
          )
          .must(            
             qb.keyword().onField("role.label").ignoreAnalyzer().matching(UserRole.ROLE_COUNTRYLEADER).createQuery()   
          ).createQuery()
       )
       .setProjection("id")
       .setResultTransformer(new ProjectionFirstResultTransformer())
       .setCacheable(true)
       .setCacheRegion(CacheRegion.NEVERCHANGE)
       .uniqueResult();
      
      nl.msw.compraventa.exceptions.SearchException: org.hibernate.search.SearchException: Unable to find field role.label in nl.msw.project.model.user.Usor
      	at nl.msw.project.dao.hibernate.SearchFacetDaoHibernate.findUsersByFacet(SearchFacetDaoHibernate.java:702)
      [...]
      Caused by: org.hibernate.search.SearchException: Unable to find field role.label in nl.msw.project.model.user.Usor
      	at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.objectToString(DocumentBuilderIndexedEntity.java:681)
      	at org.hibernate.search.query.dsl.impl.FieldContext.objectToString(FieldContext.java:86)
      	at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.buildSearchTerm(ConnectedMultiFieldsTermQueryBuilder.java:146)
      	at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:100)
      	at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:81)
      
      

      Needless to say, this worked in the past. Here's the configuration for the classes in question:

      Usor
      @Entity(name = "User2")
      @Table(name = "User")
      @org.hibernate.annotations.Table(appliesTo = "User", indexes={
      	@org.hibernate.annotations.Index(name="passwd",columnNames={"email","password"})
      })
      @Indexed
      @FullTextFilterDefs({
      	@FullTextFilterDef(name="wallFilter",impl=HibernateWallFilterFactory.class)
      })
      @AnalyzerDef(name = "userAnalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
      	@TokenFilterDef(factory = StandardFilterFactory.class),
      	@TokenFilterDef(factory = ASCIIFoldingFilterFactory.class), 
      	@TokenFilterDef(factory = LowerCaseFilterFactory.class) 
      })
      @NaturalIdCache(region=CacheRegion.NATURAL)
      @Cache(usage=CacheConcurrencyStrategy.READ_WRITE,region=CacheRegion.USER)
      public class Usor{
      	
      	@ManyToMany(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
      	@JoinTable(name = "User_UserRoles", joinColumns = @JoinColumn(nullable = false), inverseJoinColumns = @JoinColumn(nullable = false))
      	@Fetch(FetchMode.SUBSELECT)
      	@BatchSize(size=10)
      	@Cache(usage=CacheConcurrencyStrategy.READ_WRITE,region=CacheRegion.USER)
      	@IndexedEmbedded(prefix="role.")
      	@JsonIgnore
      	public Set<UserRole> getRoles() {
      		return roles;
      	}
      
      UserRole
      @Entity
      @Immutable
      @Table(name="UserRole")
      @NaturalIdCache(region=CacheRegion.NATURAL)
      @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE,region=CacheRegion.USER)
      public class UserRole implements Comparable<UserRole>, Serializable,GrantedAuthority, IEntity{
      
      	@Column(length=30,nullable=false,unique=true,updatable=false)
      	@NaturalId
      	@Index(name="idxRoleLabel")
      	@Field(index=org.hibernate.search.annotations.Index.YES,store=Store.YES,analyze=Analyze.NO)
      	public String getLabel() {
      		return label;
      	}
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: