Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Hibernate Search Sorting
PostPosted: Fri Mar 23, 2012 10:32 am 
Newbie

Joined: Fri Mar 02, 2012 10:55 am
Posts: 10
Hi guys, I have been struggling with the sort fields on 2 different entities. Any help would be appreciated.

Here is my structures:

In Entity A:
@Id
@DocumentId
@Basic(optional=false)
@SequenceGenerator(...)
@Field(index=Index.UN_TOKENIZED)
private Long a;

//a link to entity B
@JoinColumn(name="B",referencedColumnName="B")
@ManyToOne
@IndexedEmbedded
private B b;

In Entity B:
@Field(index=Index.UN_TOKENIZED)
private Long b;

I want the sort order to be ordered by B.b followed by A.a.

In my searchDAO, I code this sort.

Sort sort = new Sort(new SortField("B.b",SortField.LONG), new SortField("A.a",SortField.LONG));
searchLuceneQuery.setSort(sort);
....

The result doesn't give what i need to see to order by B.b followed by A.a.

Please help!


Top
 Profile  
 
 Post subject: Re: Hibernate Search Sorting
PostPosted: Fri Mar 23, 2012 12:57 pm 
Regular
Regular

Joined: Tue May 17, 2011 1:45 am
Posts: 52
Seems like you are trying to sort on Numberic fields so use the annotation @NumericField while declaring your fields in the entities.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.