Update: since Hibernate Search 5.7, FullTextQuery now has a type parameter. Thus we could implement this without even using a specific type. The basics would be pretty simple to add:
<T> FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class<? extends T>... entities);
<T> FullTextQuery createFullTextQuery(QueryDescriptor descriptor, Class<? extends T>... entities);
Unfortunately, the type returned by a FullTextQuery can change, in particular when one calls FullTextQuery#setProjection. The same goes with queries in Hibernate ORM and setResultTransformer, but they chose to ignore the issue by deprecating setResultTransformer. So we'll need to think about it... |