hibernate - JPA CriteriaBuilder - Expression - -
hibernate - JPA CriteriaBuilder - Expression <List> -
i have simple criteriaquery
pattern match simple search string
against field entires in person
entity... e.g searchstring
decorated %searchstring%
//using metamodel expression<list<records>> records = root.get(person_.records); expression<string> param = builder.parameter(string.class); //pseudo code(i think need here) predicate mypred = records (any record.field searchstring) path<integer> status = root.get("status"); criteriaquery.where( builder.or( builder.like( root.<string>get("name"), searchstring ), builder.like( root.<string>get("second_name"), searchstring ) //pseuso code (i lean need check predicate here?) builder.like(mypredicate) ), builder.equal(status,value) );
the person
object can contain many record
objects. update query above include similar 'like' pattern match each applicable field (string
) of each element of list of record
s. obtain record
s below:
//using metamodel expression<list<records>> records = root.get(person_.records); expression<string> param = builder.parameter(string.class);
i have updated code pseudocode of 'think' want.any help much appreciated.
as far can tell not possible using criteriaquery. need utilize sql query... here's how did it...
http://stackoverflow.com/a/24488081/1843591
hibernate jpa orm jpa-2.0 criteria-api
Comments
Post a Comment