Reputation: 1454
The Hibernate Search documentation for using a ResultTransformer gives the following example:
org.hibernate.search.FullTextQuery query =
s.createFullTextQuery( luceneQuery, Book.class );
query.setProjection( "title", "mainAuthor.name" );
query.setResultTransformer(
new StaticAliasToBeanResultTransformer(
BookView.class,
"title",
"author" )
);
List<BookView> results = (List<BookView>) query.list();
for(BookView view : results) {
log.info( "Book: " + view.getTitle() + ", " + view.getAuthor() );
}
However, the StaticAliasToBeanResultTransformer
class does not exist in the Hibernate core jar.
Does anyone know if this is supposed to be a different class that I have not been able to identify yet? Or does it exist in another Hibernate project that I have not included?
I need to accomplish this idea of mapping indexed fields to properties in my "BookView" bean, since my properties and fields are not named the same. I am using Hibernate 4.1.8 and Hibernate Search 4.1.1
Upvotes: 1
Views: 907
Reputation: 19109
Right, there is no such class. See also https://forum.hibernate.org/viewtopic.php?f=9&t=1004608. Just write your own transformer by implementing org.hibernate.transform.ResultTransformer.
Upvotes: 3
Reputation: 135
AFAIK there are no such class in Hibernate codebase. I believe it was part of the samples one day, but nowhere to be found since.
The easiest way is to write your own implementation.
Upvotes: 1