I’m trying to use JPA with HibernateSearch. I used Example 5.3 in http://docs.jboss.org/hibernate/stable/search/reference/en/html/search-query.html. The results come out as expected.
However, the data coming back is a huge graph. I only need the primary key of the data. So, I tried Example 5.9, but it only shows the Hibernate API. There was not a javax.persistence.Query.setProjection() method.
What can I use to get just the primary key of a search result? Should I try to get the hibernate session from the EntityManager in JPA?
Thanks for any help.
Example 5.3 was a bit misleading.
javax.persistence.Querydoesn’t have to be used. Instead,org.hibernate.search.jpa.FullTextQueryhas thesetProjection()method that I needed. Here is the resulting code (with fully qualified class names):query2does the projection and all is well!