I want to use MySQL\'s full text search features using JPA, without having to use a native query.
I am using EclipseLink, which has a function to support native SQL
Just to complete the answer: I had the same problem, but using the criteria builder. This is how you can get around the limitations in the standart implementation, if you are using EclipseLink:
Example:
JpaCriteriaBuilder cb = (JpaCriteriaBuilder) cb;
List args = new ArrayList();
args.add("Keyword");
Expression expr = cb.fromExpression (
cb.toExpression(
cb.function("", String.class,
table.get(Table_.text1), table.get(Table_.text2))
)
.sql("MATCH ? AGAINST (?)", args)
);
query.where(expr);
If you need to cast the expression to a predicate use the following:
query.where( cb.gt(expr, 0));