One way would be to create 3 different queries, and then in your java code examine the params and use the appropriate query. (This may not be the best way.)
Code:
@Repository
public final class SomethingDao extends SqlMapClientDaoSupport implements ISomethingDao {
private final transient Logger log = LoggerFactory.getLogger(getClass());
@Autowired
public SqlMapClient sqlMapClient;
@PostConstruct
public void init() {
this.setSqlMapClient(sqlMapClient);
}
@Override
public void somethingFondler(Something param1, Something param2, Something param3) {
getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
@SuppressWarnings("synthetic-access")
public Object doInSqlMapClient(final SqlMapExecutor executor)
throws SQLException {
executor.startBatch();
if (leftOuterJoinNeeded(param1, param2))
executor.queryForList("Something.leftOuterJoin", param1);
else if (fullOuterJoinNeeded(param1, param2))
executor.queryForList("Something.fullOuterJoin", param2);
else
executor.queryForList("Something.query", param3);
executor.executeBatch();
return (null);
}
});
}
You may not need the executor with its batch stuff; that's from the code I copied this from before I changed it for this example. The code I copied from was doing an update.