-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hib Search - annotation inheritance issues (classbridge)
PostPosted: Fri Feb 07, 2014 5:36 pm 
Newbie

Joined: Fri Feb 07, 2014 4:58 pm
Posts: 2
Hello,

Before anything else, just wanted to say Search is awesome, so thank you.

I'm having an issue with the @ClassBridge defined on an interface not inheriting to the implementing classes. I currently have a setup like the one below (simplified):

Code:
@ClassBridge(name="MY_BRIDGE",
      store=Store.YES,
      impl=MyChild.MyChildClassBridge.class)
public interface MyChild {
   public class MyChildClassBridge implements FieldBridge {

      @Override
      public void set(String name, Object value, Document document,
            LuceneOptions luceneOptions) {
         
         String fieldValue = ((MyChild) value).getConcatGroup();
         if(fieldValue == null){
            fieldValue = "";
         }

         org.apache.lucene.document.Field field =
            new org.apache.lucene.document.Field(
               name, fieldValue, luceneOptions.getStore(),
               luceneOptions.getIndex(), luceneOptions.getTermVector());

         field.setBoost(luceneOptions.getBoost());
         document.add(field);
      }
   }

   public String getConcatGroup();
}

@Entity
@Indexed
public class Pete implements MyChild{
   @Id   @GeneratedValue
   private long id;

   /**** .... simplified *****/

   public String getConcatGroup(){
      return "some string";
   }
}


Now I expected that the Pete class would inherit the ClassBridge defined on MyChild and thus I would see and index of the name "MY_BRIDGE". However when I reindex and inspect with Luke it doesn't show up. If I move the ClassBridge from the interface (MyChild) and define it directly on the Pete class then the index shows up as expected. Scouring the interwebs I only came upon the following:

https://hibernate.atlassian.net/browse/HSEARCH-249 (6 years old, unresolved)
http://stackoverflow.com/questions/17116839/how-does-hibernate-search-handle-annotations-inherited-from-a-superclass
http://stackoverflow.com/questions/1413558/hibernate-search-annotations-not-inherited

(contributions from sirs Emmanuel, Sanne, and Hardy) which also pointed to some hibernate forum posts.

Emmanuel (in the JIRA) and a SO poster seemed to indicate that the inheritance should work. Is this not the case, does it only work on actual super classes and not interfaces?, or do I have something incorrectly configured?

Many thanks in advance for any help.


Top
 Profile  
 
 Post subject: Re: Hib Search - annotation inheritance issues (classbridge)
PostPosted: Sun Feb 09, 2014 1:38 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
you're right it won't inherit from an interface: since you can have multiple interfaces that would introduce ambiguity.
It should however work to define you ClassBridge on a parent class.

And thanks for the kind words!

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Hib Search - annotation inheritance issues (classbridge)
PostPosted: Sun Feb 09, 2014 7:30 pm 
Newbie

Joined: Fri Feb 07, 2014 4:58 pm
Posts: 2
Hi Sanne,

Ok, understandable, I can live with that. I've also confirmed that it does work when inheriting from a class.

And you've got to give credit where credit is due man :).

Thanks again for the help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.