Polishing

This commit is contained in:
Juergen Hoeller
2015-11-14 23:32:36 +01:00
parent 48838d48d2
commit 71fc2ba174
20 changed files with 182 additions and 185 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,6 @@ public class SqlParameter {
/** Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types */
private String typeName;
/** The scale to apply in case of a NUMERIC or DECIMAL type, if any */
private Integer scale;
@@ -126,7 +125,7 @@ public class SqlParameter {
/**
* Return the name of the parameter.
* Return the name of the parameter, or {@code null} if anonymous.
*/
public String getName() {
return this.name;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,18 +39,19 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
* can only be used for databases that are known to provide accurate meta data.
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
* Sybase and PostgreSQL. For any other databases you are required to declare all
* parameters explicitly. You can of course declare all parameters explicitly even
* if the database provides the necessary meta data. In that case your declared
* parameters will take precedence. You can also turn off any meta data processing
* if you want to use parameter names that do not match what is declared during
* the stored procedure compilation.
* Sybase and PostgreSQL. For any other databases you are required to declare
* all parameters explicitly. You can of course declare all parameters
* explicitly even if the database provides the necessary meta data. In that
* case your declared parameters will take precedence. You can also turn off
* any metadata processing if you want to use parameter names that do not
* match what is declared during the stored procedure compilation.
*
* <p>The actual insert is being handled using Spring's
* {@link org.springframework.jdbc.core.JdbcTemplate}.
*
* <p>Many of the configuration methods return the current instance of the SimpleJdbcCall
* to provide the ability to chain multiple ones together in a "fluent" interface style.
* <p>Many of the configuration methods return the current instance of the
* SimpleJdbcCall in order to provide the ability to chain multiple ones
* together in a "fluent" interface style.
*
* @author Thomas Risberg
* @since 2.5
@@ -60,8 +61,8 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
/**
* Constructor that takes one parameter with the JDBC DataSource to use when creating the
* JdbcTemplate.
* Constructor that takes one parameter with the JDBC DataSource to use when
* creating the underlying JdbcTemplate.
* @param dataSource the {@code DataSource} to use
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,8 +103,7 @@ public class SimpleJdbcCallTests {
adder.declareParameters(
new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER),
new SqlOutParameter("newid",
Types.INTEGER));
new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource().
addValue("amount", 1103).
addValue("custid", 3));
@@ -120,8 +119,7 @@ public class SimpleJdbcCallTests {
adder.declareParameters(
new SqlParameter("amount", Types.INTEGER),
new SqlParameter("custid", Types.INTEGER),
new SqlOutParameter("newid",
Types.INTEGER));
new SqlOutParameter("newid", Types.INTEGER));
Number newId = adder.executeObject(Number.class, 1103, 3);
assertEquals(4, newId.intValue());
verifyAddInvoiceWithoutMetaData(false);
@@ -193,7 +191,8 @@ public class SimpleJdbcCallTests {
}
@Test public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
@Test
public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
initializeAddInvoiceWithMetaData(true);
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withFunctionName("add_invoice");
Number newId = adder.executeFunction(Number.class, 1103, 3);
@@ -203,8 +202,7 @@ public class SimpleJdbcCallTests {
}
private void initializeAddInvoiceWithoutMetaData(boolean isFunction)
throws SQLException {
private void initializeAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {
given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
given(databaseMetaData.getUserName()).willReturn("me");
given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);
@@ -281,6 +279,6 @@ public class SimpleJdbcCallTests {
verify(callableStatement).close();
verify(proceduresResultSet).close();
verify(procedureColumnsResultSet).close();
}
}
}