| Thanks for your suggestion. Unfortunately, I'm afraid this cannot be done in the current state of the APIs, or at least not without quite a bit of hacking. The thing is, the type returned by a FullTextQuery can change after you called createFullTextQuery, and therefore previous references to the exact same query will probably break your code (they'll appear to return MyEntityType, but will return Object[] instead). The reason the returned type can change is that we have a setProjection method on FullTextQuery which, when called, will change the return type from whatever it was originally (your entity type) to an Object[]. In any case, these changes are already being discussed in
HSEARCH-2225 Open , and we are planning to do something about it in our API changes planned for Hibernate Search 6 :
HSEARCH-2498 Open . It basically involves removing the setProjection method and forcing users to specify whether they want a projection or not before they create the query. I will close this ticket as duplicate, but feel free to re-open it if you feel that
HSEARCH-2225 Open is not the same as what you proposed. |