mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-17 22:56:28 +00:00
ENH: added SqlRow factory method to RawSqlService (#1312)
* ENH: added SqlRow factory method to RawSqlService * compile fixes * ADD: sqlRow factory also to RawSqlBuilder
This commit is contained in:
1 parent
78628ffad0
commit
aea7d937eb
3 files changed
+38
No files matched your search
@@ -2,9 +2,13 @@ package io.ebeaninternal.server.rawsql;
|
||||
|
||||
import io.ebean.RawSql;
|
||||
import io.ebean.RawSqlBuilder;
|
||||
import io.ebean.SqlRow;
|
||||
import io.ebean.service.SpiRawSqlService;
|
||||
import io.ebeaninternal.server.query.DefaultSqlRow;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DRawSqlService implements SpiRawSqlService {
|
||||
|
||||
@@ -28,4 +32,20 @@ public class DRawSqlService implements SpiRawSqlService {
|
||||
SpiRawSql.Sql s = new SpiRawSql.Sql(sql);
|
||||
return new DRawSqlBuilder(s, new SpiRawSql.ColumnMapping());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlRow sqlRow(ResultSet resultSet, String dbTrueValue) throws SQLException {
|
||||
ResultSetMetaData meta = resultSet.getMetaData();
|
||||
int estCap = (int) (meta.getColumnCount() / 0.7f) + 1;
|
||||
DefaultSqlRow ret = new DefaultSqlRow(estCap, 0.75f, dbTrueValue);
|
||||
|
||||
for (int i = 1; i <= meta.getColumnCount(); i++) {
|
||||
String name = meta.getColumnLabel(i);
|
||||
if (name == null) {
|
||||
name = meta.getColumnName(i);
|
||||
}
|
||||
ret.put(name, resultSet.getObject(i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user