目前我正在使用我的maven项目的以下配置。我想在我的代码中使用JPA(JPQL)来使用全文搜索查询。
我尝试了这个建议,但我找不到MySQL5Dialect的maven依赖,它应该与我的下面的配置兼容。
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
发布于 2019-05-29 17:08:56
我创建了方言自定义类
public class FullTextSearch extends MySQL5InnoDBDialect{
public FullTextSearch(){
super();
registerFunction("match", new SQLFunctionTemplate(new DoubleType(),"match(?1) against (?2 in boolean mode)"));
}
}
In code I call this method
Query namedQuery = em.createQuery("select user from User user " +
"where match(user.familyName,LOWER(CONCAT(:searchName,'*'))) > 0 " +
"order by user.familyName");
I add configuration in persistence.xml
<property name="hibernate.dialect" value="textsearch.FullTextSearch"/>
But I am getting an error
WebServiceException: org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException[AbstractEntityManagerImpl.java:614] threw javax.persistence.PersistenceException (org.hibernate.exception.SQLGrammarException: could not execute query)
https://stackoverflow.com/questions/-100006855
复制相似问题