This didn't help. Perhaps I did not state the problem well enough. The search presently goes against a database VIEW, not the table corresponding to the Hibernate entity I want to search. The VIEW is mapped to a different Hibernate Entity that is read-only. The VIEW mapping class has:
@org.hibernate.annotations.Entity(mutable = false)
Using projections when searching the primary entity wouldn't help, because the ManyToOne fields are from code tables. Those always have to be loaded anyway. The VIEW optimizes this by joining them in a precompiled SQL query, which is one of the benefits of using a VIEW. And Hibernate does not have to join anything to the VIEW object.
From the number of reads of this post, compared to the number of answers, I am concluding that this simply is impossible with Hibernate Search. It can only be used to search for the same Entities that are mapped into Lucene.
I would have to completely reimplement the search and ditch the VIEW approach. That would require a great deal of change to the application. Thus it appears that though Hibernate Search would yield performance gains during search, in this case it would incur significant development cost and change risk.
Thanks.
_________________ Richard Brewster
Senior Associate
Perrin Quarles Associates
|