jpa 2.0 - Bind specific parameter (one) in JPQL -
jpa 2.0 - Bind specific parameter (one) in JPQL -
in database have partitioning table column 'status' improve performance. database administrator inquire me set in query value column straight in sql (not bind parameter).
i can alter binding set hint queryhints.bind_parameters on false, parameters within sql.
can set not bind on 'status' parameter ?
example result when bind_parameters = true
select t0.* s_jobs_org_unit_cfg t0 ((((t0.org_id = ?) , (t0.scheduler_next_activation < sysdate)) , (t0.active = ?)) , not exists (select ? s_jobs t1 (((t1.order_id = t0.order_id) , (t1.org_id = t0.org_id)) , not ((t1.status = ?)))) ) bind => [472100, y, 1, e]
and result when bind_parameters = false
select t0.* s_jobs_org_unit_cfg t0 ((((t0.org_id = 472100) , (t0.scheduler_next_activation < sysdate)) , (t0.active = y)) , not exists (select 1 s_jobs t1 (((t1.order_id = t0.order_id) , (t1.org_id = t0.org_id)) , not ((t1.status = e)))) )
code:
query joborgunitcfgquery = entitymanager.createquery( "select c joborgunitcfg c c.orgid = :orgid , c.schedulernextactivation < current_timestamp , c.active = :active , " + " not exists (select j job j j.orderid = c.orderid , j.orgid = c.orgid , j.status <> 'e')"); joborgunitcfgquery.setparameter("orgid", orgid); joborgunitcfgquery.setparameter("active", boolean.true); homecoming joborgunitcfgquery.getresultlist();
i think best bet programmatically build query you're doing hard coded status , escape other paramaters manually avoid sql injection.
jpa-2.0 bind eclipselink jpql
Comments
Post a Comment