#1312 - ENH: added SqlRow factory method to RawSqlService

Support the PR added binaryOptimizedUUID
This commit is contained in:
Rob Bygrave
2018-03-02 13:25:55 +13:00
parent b642b3c644
commit 54530248a5
3 changed files with 11 additions and 9 deletions
+3 -5
View File
@@ -26,12 +26,10 @@ public interface RawSqlBuilder {
}
/**
* Create and return a SqlRow based on the resultSet and the dbTrueValue.
* @throws SQLException
* Create and return a SqlRow based on the resultSet with dbTrueValue and binaryOptimizedUUID options.
*/
static SqlRow sqlRow(ResultSet resultSet, final String dbTrueValue) throws SQLException {
return XServiceProvider.rawSql().sqlRow(resultSet, dbTrueValue);
static SqlRow sqlRow(ResultSet resultSet, final String dbTrueValue, boolean binaryOptimizedUUID) throws SQLException {
return XServiceProvider.rawSql().sqlRow(resultSet, dbTrueValue, binaryOptimizedUUID);
}
/**
@@ -29,7 +29,10 @@ public interface SpiRawSqlService {
/**
* Create based on a JDBC ResultSet.
* @throws SQLException
*
* @param resultSet The ResultSet row to read as a SqlRow
* @param dbTrueValue The DB true value
* @param binaryOptimizedUUID Flag set to true if the UUID value is stored as optimised binary(16)
*/
SqlRow sqlRow(ResultSet resultSet, String dbTrueValue) throws SQLException;
SqlRow sqlRow(ResultSet resultSet, String dbTrueValue, boolean binaryOptimizedUUID) throws SQLException;
}
@@ -34,10 +34,11 @@ public class DRawSqlService implements SpiRawSqlService {
}
@Override
public SqlRow sqlRow(ResultSet resultSet, String dbTrueValue) throws SQLException {
public SqlRow sqlRow(ResultSet resultSet, String dbTrueValue, boolean binaryOptimizedUUID) throws SQLException {
ResultSetMetaData meta = resultSet.getMetaData();
int estCap = (int) (meta.getColumnCount() / 0.7f) + 1;
DefaultSqlRow ret = new DefaultSqlRow(estCap, 0.75f, dbTrueValue);
DefaultSqlRow ret = new DefaultSqlRow(estCap, 0.75f, dbTrueValue, binaryOptimizedUUID);
for (int i = 1; i <= meta.getColumnCount(); i++) {
String name = meta.getColumnLabel(i);