Not able to build a criteria with "like expression" [message #1008463] |
Tue, 12 February 2013 15:29 |
|
Hi,
I am trying to build a criteria query with a like expression, but I am not able to find a way, it compiles. I tried the following and some hints from the wiki, but no success so far.
CriteriaBuilder cb = getEntityManger().getCriteriaBuilder();
CriteriaQuery<ST> cr = cb.createQuery(searchType);
Root<ST> root = (Root<ST>) cr.from(searchType);
EntityType<ST> type = getEntityManger().getMetamodel().entity(searchType);
String field = "name";
if (StringUtils.isNotEmpty(enteredValue)){
Predicate and = cb.Like(root.get(field), "Jeff");
cr.where(and);
}
I am using latest eclipselink stable version I think.
Here is a list of jars:
javax.persistence_2.0.4.v201112161009.jar
eclipselink-jpa-modelgen_2.4.1.v20121003-ad44345.jar
eclipselink.jar
Any help would be great, spent hours
Thank you
Marcus
|
|
|
|
Powered by
FUDForum. Page generated in 0.03357 seconds