query results with hibernate-search with associated enumeration field












0















I am trying to make document index of the Entity that has following associations:



DocVersion:



@Entity
@Indexed
public class DocVersion implements Serializable {
...
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "doc_uuid")
@IndexedEmbedded
private Document2 document2;
...
}


Document2:



@Entity
@Indexed
public class Document2 implements Serializable {
...
@Column(name = "entityState")
@Enumerated(EnumType.STRING)
@Field(bridge=@FieldBridge(impl=EnumBridge.class), index=Index.YES)
private EDocState eDocState;
...
}


this is how I query the index (just for testing purposes):



FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
try {
fullTextEntityManager.createIndexer().startAndWait();
} catch (InterruptedException e) {
e.printStackTrace();
}

QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
.buildQueryBuilder()
.forEntity(DocVersion.class)
.get();

org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
.onField("document2.eDocState").matching("HARD_DEL")
.createQuery();
List results = fullTextEntityManager.createFullTextQuery(luceneQuery, DocVersion.class)
.getResultList();


but instead of results I get:



WARNING: org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
entity class: com.nws.vedica.model.entity.DocVersion
entity property path: document2.eDocState
field bridge: TwoWayString2FieldBridgeAdaptor [stringBridge=org.hibernate.search.bridge.builtin.EnumBridge@60942b8b]


So what does that mean? Do I need to implement some specific bridge for an Enumeration (how would that look like)?
It's just value enum so I think problem is somewhere else.



Please assist me to get the results.



package I'm using:
hibernate-search-orm: 5.9.3.










share|improve this question



























    0















    I am trying to make document index of the Entity that has following associations:



    DocVersion:



    @Entity
    @Indexed
    public class DocVersion implements Serializable {
    ...
    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "doc_uuid")
    @IndexedEmbedded
    private Document2 document2;
    ...
    }


    Document2:



    @Entity
    @Indexed
    public class Document2 implements Serializable {
    ...
    @Column(name = "entityState")
    @Enumerated(EnumType.STRING)
    @Field(bridge=@FieldBridge(impl=EnumBridge.class), index=Index.YES)
    private EDocState eDocState;
    ...
    }


    this is how I query the index (just for testing purposes):



    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
    try {
    fullTextEntityManager.createIndexer().startAndWait();
    } catch (InterruptedException e) {
    e.printStackTrace();
    }

    QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
    .buildQueryBuilder()
    .forEntity(DocVersion.class)
    .get();

    org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
    .onField("document2.eDocState").matching("HARD_DEL")
    .createQuery();
    List results = fullTextEntityManager.createFullTextQuery(luceneQuery, DocVersion.class)
    .getResultList();


    but instead of results I get:



    WARNING: org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
    entity class: com.nws.vedica.model.entity.DocVersion
    entity property path: document2.eDocState
    field bridge: TwoWayString2FieldBridgeAdaptor [stringBridge=org.hibernate.search.bridge.builtin.EnumBridge@60942b8b]


    So what does that mean? Do I need to implement some specific bridge for an Enumeration (how would that look like)?
    It's just value enum so I think problem is somewhere else.



    Please assist me to get the results.



    package I'm using:
    hibernate-search-orm: 5.9.3.










    share|improve this question

























      0












      0








      0








      I am trying to make document index of the Entity that has following associations:



      DocVersion:



      @Entity
      @Indexed
      public class DocVersion implements Serializable {
      ...
      @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      @JoinColumn(name = "doc_uuid")
      @IndexedEmbedded
      private Document2 document2;
      ...
      }


      Document2:



      @Entity
      @Indexed
      public class Document2 implements Serializable {
      ...
      @Column(name = "entityState")
      @Enumerated(EnumType.STRING)
      @Field(bridge=@FieldBridge(impl=EnumBridge.class), index=Index.YES)
      private EDocState eDocState;
      ...
      }


      this is how I query the index (just for testing purposes):



      FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
      try {
      fullTextEntityManager.createIndexer().startAndWait();
      } catch (InterruptedException e) {
      e.printStackTrace();
      }

      QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
      .buildQueryBuilder()
      .forEntity(DocVersion.class)
      .get();

      org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
      .onField("document2.eDocState").matching("HARD_DEL")
      .createQuery();
      List results = fullTextEntityManager.createFullTextQuery(luceneQuery, DocVersion.class)
      .getResultList();


      but instead of results I get:



      WARNING: org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
      entity class: com.nws.vedica.model.entity.DocVersion
      entity property path: document2.eDocState
      field bridge: TwoWayString2FieldBridgeAdaptor [stringBridge=org.hibernate.search.bridge.builtin.EnumBridge@60942b8b]


      So what does that mean? Do I need to implement some specific bridge for an Enumeration (how would that look like)?
      It's just value enum so I think problem is somewhere else.



      Please assist me to get the results.



      package I'm using:
      hibernate-search-orm: 5.9.3.










      share|improve this question














      I am trying to make document index of the Entity that has following associations:



      DocVersion:



      @Entity
      @Indexed
      public class DocVersion implements Serializable {
      ...
      @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      @JoinColumn(name = "doc_uuid")
      @IndexedEmbedded
      private Document2 document2;
      ...
      }


      Document2:



      @Entity
      @Indexed
      public class Document2 implements Serializable {
      ...
      @Column(name = "entityState")
      @Enumerated(EnumType.STRING)
      @Field(bridge=@FieldBridge(impl=EnumBridge.class), index=Index.YES)
      private EDocState eDocState;
      ...
      }


      this is how I query the index (just for testing purposes):



      FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
      try {
      fullTextEntityManager.createIndexer().startAndWait();
      } catch (InterruptedException e) {
      e.printStackTrace();
      }

      QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
      .buildQueryBuilder()
      .forEntity(DocVersion.class)
      .get();

      org.apache.lucene.search.Query luceneQuery = queryBuilder.keyword()
      .onField("document2.eDocState").matching("HARD_DEL")
      .createQuery();
      List results = fullTextEntityManager.createFullTextQuery(luceneQuery, DocVersion.class)
      .getResultList();


      but instead of results I get:



      WARNING: org.hibernate.search.bridge.BridgeException: Exception while calling bridge#objectToString
      entity class: com.nws.vedica.model.entity.DocVersion
      entity property path: document2.eDocState
      field bridge: TwoWayString2FieldBridgeAdaptor [stringBridge=org.hibernate.search.bridge.builtin.EnumBridge@60942b8b]


      So what does that mean? Do I need to implement some specific bridge for an Enumeration (how would that look like)?
      It's just value enum so I think problem is somewhere else.



      Please assist me to get the results.



      package I'm using:
      hibernate-search-orm: 5.9.3.







      java lucene hibernate-search






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 23:06









      greengoldgreengold

      4212922




      4212922
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You don't need to implement a specific bridge, actually it's quite the opposite: a bridge is already there, so Hibernate Search expects you to pass enum values to the query, and you're passing String values instead.



          Try replacing .matching("HARD_DEL") with .matching(EDocState.HARD_DEL).



          Note: I suspect the rest of the stack trace would tell you something about a class cast exception, which could have tipped you off. For your own sake, you should probably not hide stack traces like that, stack traces may contain valuable information.






          share|improve this answer
























          • yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

            – greengold
            Nov 22 '18 at 10:27











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421689%2fquery-results-with-hibernate-search-with-associated-enumeration-field%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You don't need to implement a specific bridge, actually it's quite the opposite: a bridge is already there, so Hibernate Search expects you to pass enum values to the query, and you're passing String values instead.



          Try replacing .matching("HARD_DEL") with .matching(EDocState.HARD_DEL).



          Note: I suspect the rest of the stack trace would tell you something about a class cast exception, which could have tipped you off. For your own sake, you should probably not hide stack traces like that, stack traces may contain valuable information.






          share|improve this answer
























          • yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

            – greengold
            Nov 22 '18 at 10:27
















          0














          You don't need to implement a specific bridge, actually it's quite the opposite: a bridge is already there, so Hibernate Search expects you to pass enum values to the query, and you're passing String values instead.



          Try replacing .matching("HARD_DEL") with .matching(EDocState.HARD_DEL).



          Note: I suspect the rest of the stack trace would tell you something about a class cast exception, which could have tipped you off. For your own sake, you should probably not hide stack traces like that, stack traces may contain valuable information.






          share|improve this answer
























          • yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

            – greengold
            Nov 22 '18 at 10:27














          0












          0








          0







          You don't need to implement a specific bridge, actually it's quite the opposite: a bridge is already there, so Hibernate Search expects you to pass enum values to the query, and you're passing String values instead.



          Try replacing .matching("HARD_DEL") with .matching(EDocState.HARD_DEL).



          Note: I suspect the rest of the stack trace would tell you something about a class cast exception, which could have tipped you off. For your own sake, you should probably not hide stack traces like that, stack traces may contain valuable information.






          share|improve this answer













          You don't need to implement a specific bridge, actually it's quite the opposite: a bridge is already there, so Hibernate Search expects you to pass enum values to the query, and you're passing String values instead.



          Try replacing .matching("HARD_DEL") with .matching(EDocState.HARD_DEL).



          Note: I suspect the rest of the stack trace would tell you something about a class cast exception, which could have tipped you off. For your own sake, you should probably not hide stack traces like that, stack traces may contain valuable information.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 7:26









          yrodiereyrodiere

          2,5911315




          2,5911315













          • yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

            – greengold
            Nov 22 '18 at 10:27



















          • yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

            – greengold
            Nov 22 '18 at 10:27

















          yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

          – greengold
          Nov 22 '18 at 10:27





          yeah, that's right. don't know why I didn't try it all day long... maybe I need to tune my logback a little more. thanks.

          – greengold
          Nov 22 '18 at 10:27


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421689%2fquery-results-with-hibernate-search-with-associated-enumeration-field%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen