|append Postgres Full Text Search expression after having CriteriaQuery [message #1272703]
||Tue, 18 March 2014 14:44
| Clovis Wichoski
Registered: March 2012
I have a scenario where the user create some filters using CriteriaQuery, but one of that filter was a free search field, I wish to get the EclipseLink generated SQL and append the a String on that SQL, but the DatabaseQuery returns null from CriteriaQuery, here is the algorithm idea:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery();
//populates cq suppressed content
TypedQuery q = em.createQuery(cq);
String generatedSQL = q.unwrap(JpaQuery.class).getDatabaseQuery().getSQLString();
String nativeSQL = generatedSQL + " AND buscaLivre @@ to_tsquery('ELX')";
ps: buscaLivre is the field that allow the full text search.
This dont works as the content of generatedSQL is null then the nativeSQL string get the value "null AND buscaLivre @@ to_tsquery('ELX')".
I tried to find some way to inject this expression on where part of criteria, but dont found a native() method, if that exists that would be great, but as dont exists I tried to concat SQL strings, any way to get that SQL? anyone have a better approach for that?
Powered by FUDForum
. Page generated in 0.04297 seconds