-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with IndexReader and inheritance
PostPosted: Tue Dec 21, 2010 5:01 am 
Regular
Regular

Joined: Thu Nov 26, 2009 8:45 am
Posts: 78
Hi,

im using HS 3.0.1 with Hibernate 3.2.6.

I've annotated a class, which has just 3 Fields on its own (to index), but a lot of fields which it is inheriting from its superclass.
Now i want to get all the fields that are indexed on this class. With the use of IndexReader.getFieldNames(FieldOption.All) i get to it successfully with
the superclass, but applying that code to the inherited one, i get back an emtpy collection. Can anyone tell me how to get the (indexed) fields of the inheriting one?

my code:
Code:
      DirectoryProvider<?> provider = null;

      ReaderProvider readerProvider = fSession.getSearchFactory()
            .getReaderProvider();

      IndexReader indexReader = null;

      try {
         for (Class<?> c : classes) {
            if (sFactory != null) {
               DirectoryProvider<?>[] provArr = sFactory
                     .getDirectoryProviders(c);
               if (provArr != null) {
                  provider = sFactory.getDirectoryProviders(c)[0];
                  if (provider != null) {
                     indexReader = readerProvider.openReader(provider);
                     Collection<?> tmpFields = indexReader
                           .getFieldNames(FieldOption.INDEXED);


superclass Attribute.java:
Code:
@Entity
public abstract class Attribute implements Serializable {

    @DocumentId
    private Integer id = null;

    @display
    @Field
    private Boolean active = Boolean.FALSE;

    ...


inherited class AttributeFA.java:
Code:
@Entity
@Indexed
public class AttributeFA extends Attribute {
   private static final long serialVersionUID = 1L;

   @display
   @Field
   private String   att1         = null;
   
   @display
   @Field
   private String   att2         = null;
   
   @display
   @Field
   private String   att3      = null;

         ...


Top
 Profile  
 
 Post subject: Re: Problem with IndexReader and inheritance
PostPosted: Tue Dec 21, 2010 6:58 am 
Regular
Regular

Joined: Thu Nov 26, 2009 8:45 am
Posts: 78
Problem solved. After rebuilding the index it works suprisingly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.