criteria - Jpa QueryBuilder Multiple expressions in where clause not working -
i having issue creating queries javax.persistence.criteria.criteriabuilder. using eclipselink 2.1 , oracle 10g database. when building query multiple restrictions use first restriction, not both of them.
here code:
criteriabuilder cb = getem().getcriteriabuilder(); criteriaquery<assignment> query = cb.createquery(assignment.class); root<assignment> assignment = query.from(assignment.class); query.where( cb.equal(assignment.get("request"), request), cb.isnull(assignment.get("enddate"))); return getem().createquery(query).getresultlist(); the query producted is:
select assx_id, end_date, begin_date, comments, assx_oer_assigned_to_id, oer_oer_id_assigned_by, assx_rqst_id tarts.assignment_xref (assx_rqst_id = ?) it looks except clause. expecting:
select assx_id, end_date, begin_date, comments, assx_oer_assigned_to_id, oer_oer_id_assigned_by, assx_rqst_id tarts.assignment_xref (assx_rqst_id = ? , begin_date not null) it doesn't matter if use cb.and(arg1, arg2) or not also. doing wrong? appreciated.
your query looks ok. you've mentioned, criteriaquery.where(predicate... restrictions) uses conjunction of predicates there's no need use cb.and().
the things imagine:
- bug in eclipselink (try same hibernate)
- some sort of optimization, maybe
enddatemay never null? - your getem() method strange things
Comments
Post a Comment