Java 类org.springframework.jdbc.core.SqlInOutParameter 实例源码

项目:spring4-understanding    文件:RdbmsOperationTests.java   
@Test
public void validateInOutParameter() {
    operation.setDataSource(new DriverManagerDataSource());
    operation.setSql("DUMMY_PROC");
    operation.declareParameter(new SqlOutParameter("DUMMY_OUT_PARAM", Types.VARCHAR));
    operation.declareParameter(new SqlInOutParameter("DUMMY_IN_OUT_PARAM", Types.VARCHAR));
    operation.validateParameters(new Object[] {"DUMMY_VALUE1", "DUMMY_VALUE2"});
}
项目:spring4-understanding    文件:CallMetaDataContextTests.java   
@Test
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
    final String TABLE = "customers";
    final String USER = "me";
    given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
    given(databaseMetaData.getUserName()).willReturn(USER);
    given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);

    List<SqlParameter> parameters = new ArrayList<SqlParameter>();
    parameters.add(new SqlParameter("id", Types.NUMERIC));
    parameters.add(new SqlInOutParameter("name", Types.NUMERIC));
    parameters.add(new SqlOutParameter("customer_no", Types.NUMERIC));

    MapSqlParameterSource parameterSource = new MapSqlParameterSource();
    parameterSource.addValue("id", 1);
    parameterSource.addValue("name", "Sven");
    parameterSource.addValue("customer_no", "12345XYZ");

    context.setProcedureName(TABLE);
    context.initializeMetaData(dataSource);
    context.processParameters(parameters);

    Map<String, Object> inParameters = context.matchInParameterValuesWithCallParameters(parameterSource);
    assertEquals("Wrong number of matched in parameter values", 2, inParameters.size());
    assertTrue("in parameter value missing", inParameters.containsKey("id"));
    assertTrue("in out parameter value missing", inParameters.containsKey("name"));
    assertTrue("out parameter value matched", !inParameters.containsKey("customer_no"));

    List<String> names = context.getOutParameterNames();
    assertEquals("Wrong number of out parameters", 2, names.size());

    List<SqlParameter> callParameters = context.getCallParameters();
    assertEquals("Wrong number of call parameters", 3, callParameters.size());
}
项目:class-guard    文件:RdbmsOperationTests.java   
public void testValidateInOutParameter() {
    TestRdbmsOperation operation = new TestRdbmsOperation();
    operation.setDataSource(new DriverManagerDataSource());
    operation.setSql("DUMMY_PROC");
    operation.declareParameter(new SqlOutParameter("DUMMY_OUT_PARAM", Types.VARCHAR));
    operation.declareParameter(new SqlInOutParameter("DUMMY_IN_OUT_PARAM", Types.VARCHAR));
    operation.validateParameters(new Object[] {"DUMMY_VALUE1", "DUMMY_VALUE2"});
}
项目:class-guard    文件:CallMetaDataContextTests.java   
@Test
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
    final String TABLE = "customers";
    final String USER = "me";
    given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
    given(databaseMetaData.getUserName()).willReturn(USER);
    given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);

    List<SqlParameter> parameters = new ArrayList<SqlParameter>();
    parameters.add(new SqlParameter("id", Types.NUMERIC));
    parameters.add(new SqlInOutParameter("name", Types.NUMERIC));
    parameters.add(new SqlOutParameter("customer_no", Types.NUMERIC));

    MapSqlParameterSource parameterSource = new MapSqlParameterSource();
    parameterSource.addValue("id", 1);
    parameterSource.addValue("name", "Sven");
    parameterSource.addValue("customer_no", "12345XYZ");

    context.setProcedureName(TABLE);
    context.initializeMetaData(dataSource);
    context.processParameters(parameters);

    Map<String, Object> inParameters = context.matchInParameterValuesWithCallParameters(parameterSource);
    assertEquals("Wrong number of matched in parameter values", 2, inParameters.size());
    assertTrue("in parameter value missing", inParameters.containsKey("id"));
    assertTrue("in out parameter value missing", inParameters.containsKey("name"));
    assertTrue("out parameter value matched", !inParameters.containsKey("customer_no"));

    List<String> names = context.getOutParameterNames();
    assertEquals("Wrong number of out parameters", 2, names.size());

    List<SqlParameter> callParameters = context.getCallParameters();
    assertEquals("Wrong number of call parameters", 3, callParameters.size());
}
项目:lams    文件:GenericCallMetaDataProvider.java   
@Override
public SqlParameter createDefaultInOutParameter(String parameterName, CallParameterMetaData meta) {
    return new SqlInOutParameter(parameterName, meta.getSqlType());
}
项目:spring4-understanding    文件:GenericCallMetaDataProvider.java   
@Override
public SqlParameter createDefaultInOutParameter(String parameterName, CallParameterMetaData meta) {
    return new SqlInOutParameter(parameterName, meta.getSqlType());
}
项目:class-guard    文件:GenericCallMetaDataProvider.java   
public SqlParameter createDefaultInOutParameter(String parameterName, CallParameterMetaData meta) {
    return new SqlInOutParameter(parameterName, meta.getSqlType());
}
项目:trainings    文件:PersonMappingQuery.java   
public PersonMappingQuery(DataSource ds) {
    super(ds, "select id, name, age from person where id = ?");
    super.declareParameter(new SqlInOutParameter("id", Types.INTEGER));
    compile();
}