I
iksrazal
Hi all,
I'm recieving a Bean from a web page that has something like 50
parameters, only one is mandatory. The idea is to use all these
parameters for a big select, filtering out data and returning what is
seached for. Any idea for something better than lots of 'if'
statements? For example...
private void createSelect(StringBuffer query, TrackerFilter param)
{
query.append("select distinct act from Activity act ");
if (param.getClientName() != null)
{
query.append("join act.clientInfo client");
}
// much more of the same
}
private void setParameters(Query
query, TrackerFilter param)
{
if (param.getClientName() != null)
{
query.setParameter("clientName", param.getClientName() + "%");
}
// much more of the same
}
Any ideas?
iksrazal
I'm recieving a Bean from a web page that has something like 50
parameters, only one is mandatory. The idea is to use all these
parameters for a big select, filtering out data and returning what is
seached for. Any idea for something better than lots of 'if'
statements? For example...
private void createSelect(StringBuffer query, TrackerFilter param)
{
query.append("select distinct act from Activity act ");
if (param.getClientName() != null)
{
query.append("join act.clientInfo client");
}
// much more of the same
}
private void setParameters(Query
query, TrackerFilter param)
{
if (param.getClientName() != null)
{
query.setParameter("clientName", param.getClientName() + "%");
}
// much more of the same
}
Any ideas?
iksrazal