-->
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: [Search] Sorting doesn't work with inheritance
PostPosted: Mon Mar 25, 2013 1:18 pm 
Newbie

Joined: Tue Jul 19, 2011 2:16 pm
Posts: 19
Hi Hibernators :)

I'm using Hibernate Search 4.1.1.Final.
Since few days, I try to sort my results by date. After many reworks, I think that my sort didn't work because the field is declared in a parent class.

Here is my parent class :
Code:
@MappedSuperclass
public abstract class AbstractDomainEntity implements Serializable {
   //...
   @Column
   @Field(analyze=Analyze.NO) @DateBridge(resolution=Resolution.SECOND)
   private Date lastUpdate= new Date();
   //...
}

Here is my concrete class :
Code:
@Indexed(interceptor=IndexSoftDeleteInterceptor.class)
public class ConcreteClass extends AbstractDomainEntity {
   //...
   @Column
   @Field(analyze=Analyze.NO) @DateBridge(resolution=Resolution.SECOND)
   private Date lastUpdateTest = new Date();
   //...
}

Here, the results are not sorted :
Code:
Sort sort = new Sort(new SortField("lastUpdate", SortField.STRING, REVERTED));
ftQuery.setSort(sort);

Here, the results are sorted :
Code:
Sort sort = new Sort(new SortField("lastUpdateTest", SortField.STRING, REVERTED));
ftQuery.setSort(sort);


How can I sort by lastUpdate ?


Last edited by andlio on Fri Mar 29, 2013 11:56 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [Search] Sorting doesn't work with inheritance
PostPosted: Fri Mar 29, 2013 9:34 am 
Beginner
Beginner

Joined: Mon Apr 11, 2011 7:56 am
Posts: 38
Not sure if it is required, but does the parent class have the @Indexed annotation? I think Hibernate Search will only index fields for @Indexed classes.

And do you see the field 'lastUpdate' in luke?

ps: you need to fix the example code for sorting, it uses the french field names, where you have english properties in the java class.


Top
 Profile  
 
 Post subject: Re: [Search] Sorting doesn't work with inheritance
PostPosted: Fri Mar 29, 2013 11:56 am 
Newbie

Joined: Tue Jul 19, 2011 2:16 pm
Posts: 19
Hi Elmer, (Elmervc from #Lucene IRC channel !?)

You're right ! My abstract superclass is not @Indexed... I did it, and it works now :)
And you're right about my code too, it's fixed ;)

Thank you very much !


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.