hi,
I'm trying to implement some dynamic queries in springs dao framework. What i'm essentially trying to do is supply some parameters for other things than real sql parameters.
Essentially this is a paging query. Where I want the and v_key > ? to be configurable to either greather or lesser.
Should I parse the sql string myself or is there a sort of solution allready ??
Regards,
Kees Jan Voogd
private class KeyPageListMappingQuery extends MappingSqlQuery {
private final static String sql =
""
+ " SELECT "
+ " k_uid as id, "
+ " f_b_uid as b_id, "
+ " v_key as akey, "
+ " v_dscrpt as description "
+ " FROM tb_key "
+ " WHERE "
+ " f_b_uid = ? "
+ " and v_key ? ? " // > is an opteration an cannot be replace by a parameter....
+ " ORDER BY v_key limit ?";
public KeyPageListMappingQuery(DataSource ds) {
super(ds, sql);
super.declareParameter(new SqlParameter(Types.INTEGER));
super.declareParameter(new SqlParameter(Types.CHAR));
super.declareParameter(new SqlParameter(Types.CHAR));
super.declareParameter(new SqlParameter(Types.INTEGER));
super.compile();
}
public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
Key key = new Key();
key.setKey(rs.getString("akey"));
key.setBundleId( new Integer(rs.getInt("b_id")));
key.setDescription(rs.getString("description"));
key.setId(new Integer(rs.getInt("id")));
return key;
}
} // end inner class


Reply With Quote