How to Customize the NamedQuery in EclipseLink as we do in BirtReport.
Below is Query and Customized Where clause for Birt Report
Is this possible to Customize like this for EclispeLink, your help is much appreciated.
Query
select customernumber from orders
Customized Where Clause for Query
<![CDATA[
var parmcount = params["parmorders"].value.length
var whereclause = "";
if( parmcount > 0 ){
whereclause = " where customernumber in ( ";
}
for( i=0; i < parmcount; i++ ){
if( i == 0 ){
whereclause = whereclause + params["parmorders"].value[i];
}else{
whereclause = whereclause + " , " + params["parmorders"].value[i];
}
}
if( parmcount > 0 ){
this.queryText = this.queryText + whereclause + " ) ";
}
]]>
From Documentation :
So,
NamedQuerycan’t be changed at runtime. Also as the number of parameter changes, the query will change. Therefore it isn’t feasible to useNamedQueryfor this particular case.But you can try creating query & appending conditions to it dynamically at runtime based on parameters, just like posted in your code.
Also, you can use keyword
INdirectly & setting the List as parameter to eliminate iteration.