When your Maven-based project includes the hibernate-search
dependency, it automatically pulls over three dozen related
dependencies for you. Unfortunately, JPA query support is not one of them. To use JPA-style queries, we must declare an extra hibernate-entitymanager
dependency ourselves.
Its version needs to match the version of hibernate-core
that is already in the dependency hierarchy. This will not always be in sync with the hibernate-search
version.
Your IDE may offer a way to present the dependency hierarchy visually. Either way, you can always use Maven from the command line to get the same information with this command:
mvn dependency:tree
As shown in this output, Hibernate Search version 4.2.0.Final uses core Hibernate ORM version 4.1.9.Final. So a hibernate-entitymanager
dependency should be added to the POM, using the same version as core:
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.9.Final</version>
</dependency>
...