Skip to content
Snippets Groups Projects
Commit b541811c authored by brinn's avatar brinn
Browse files

add: method IDataSourceQueryService.insertMultiKeys()

SVN: 22307
parent 6f25d186
No related branches found
No related tags found
No related merge requests found
......@@ -103,4 +103,24 @@ public class DataSourceQueryService implements IDataSourceQueryService
return insert(dataSourceName, query, new Object[0]);
}
public Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns,
String query, Object... parameters) throws IllegalArgumentException
{
final DataSource dataSource = getDataSourceProvider().getDataSource(dataSourceName);
try
{
return QueryTool.insertMultiKeys(dataSource, generatedIdColumns, query, parameters);
} catch (InvalidQueryException ex)
{
operationLog.error(ex.getCause().getMessage());
throw ex;
}
}
public Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns,
String query) throws IllegalArgumentException
{
return insertMultiKeys(dataSourceName, generatedIdColumns, query, new Object[0]);
}
}
......@@ -44,10 +44,13 @@ import net.lemnik.eodsql.DataSet;
* result.close()
* </pre>
*
* {@link #update(String, String, Object...)} and {@link #insert(String, String, Object...)} are for
* performing statements that don't return a result. Use {@link #insert(String, String, Object...)}
* if you need to get an auto-generated key of an insert statement, that is if you have a key that
* is doing an <code>AUTO_INCREMENT</code> of some sort.
* Use {@link #update(String, String, Object...)} for performing statements that don't return a
* result.
* <p>
* Use {@link #insert(String, String, Object...)} or
* {@link #insertMultiKeys(String, String[], String, Object...)} if you need to get an
* auto-generated key of an insert statement, that is if you have a key that is doing an
* <code>AUTO_INCREMENT</code> of some sort.
*
* @author Chandrasekhar Ramakrishnan
*/
......@@ -146,4 +149,39 @@ public interface IDataSourceQueryService
*/
long insert(String dataSourceName, String query, Object... parameters)
throws IllegalArgumentException;
/**
* Execute an insert against the data source with the specified name.
*
* @param dataSourceName The name of the data source to query against, as declared in the
* service.properties file.
* @param generatedIdColumns The column names of the auto-generated ids, or <code>null</code>,
* if the columns automatically detected by the driver should be used.
* @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X
* is the parameter number.
* @return The generated key of the insert statement, or -1, of no key was generated
* @throw IllegalArgumentException Throws if there is no data source with the given name.
* @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match
* the given parameters.
*/
Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns,
String query) throws IllegalArgumentException;
/**
* Execute an insert against the data source with the specified name.
*
* @param dataSourceName The name of the data source to query against, as declared in the
* service.properties file.
* @param generatedIdColumns The column names of the auto-generated ids, or <code>null</code>,
* if the columns automatically detected by the driver should be used.
* @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X
* is the parameter number.
* @param parameters The values for filling in the query parameters.
* @return The generated key of the insert statement, or -1, of no key was generated
* @throw IllegalArgumentException Thrown if there is no data source with the given name.
* @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match
* the given parameters.
*/
Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns,
String query, Object... parameters) throws IllegalArgumentException;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment