public String getOrginalName() { return parent != null ? parent.getOrginalName() : getName(); } }
public String getOrginalName() { return parent != null ? parent.getOrginalName() : getName(); } }
private static List<String> getPrimaryKeys(Connection connection, ResultSetMetaData resultSetMetaData, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider) throws SQLException { List<String> primaryKeys = new ArrayList<String>(); for(int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { JdbcColumnKey key = JdbcColumnKey.of(resultSetMetaData, i); if (columnDefinitionProvider.getColumnDefinition(key).has(KeyProperty.class)) { primaryKeys.add(key.getName()); } } if (!primaryKeys.isEmpty()) { return primaryKeys; } String catalogName = resultSetMetaData.getCatalogName(1); String schemaName = resultSetMetaData.getSchemaName(1); String tableName = resultSetMetaData.getTableName(1); try { ResultSet set = connection.getMetaData().getPrimaryKeys(catalogName, schemaName, tableName); try { while (set.next()) { primaryKeys.add(set.getString("COLUMN_NAME")); } } finally { set.close(); } } catch (SQLSyntaxErrorException e) { // ignore likely mysql view issues } return primaryKeys; }
private static List<String> getPrimaryKeys(Connection connection, ResultSetMetaData resultSetMetaData, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider) throws SQLException { List<String> primaryKeys = new ArrayList<String>(); for(int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { JdbcColumnKey key = JdbcColumnKey.of(resultSetMetaData, i); if (columnDefinitionProvider.getColumnDefinition(key).has(KeyProperty.class)) { primaryKeys.add(key.getName()); } } if (!primaryKeys.isEmpty()) { return primaryKeys; } String catalogName = resultSetMetaData.getCatalogName(1); String schemaName = resultSetMetaData.getSchemaName(1); String tableName = resultSetMetaData.getTableName(1); try { ResultSet set = connection.getMetaData().getPrimaryKeys(catalogName, schemaName, tableName); try { while (set.next()) { primaryKeys.add(set.getString("COLUMN_NAME")); } } finally { set.close(); } } catch (SQLSyntaxErrorException e) { // ignore likely mysql view issues } return primaryKeys; }
@Override protected JdbcColumnKey newKey(String column, int i, FieldMapperColumnDefinition<JdbcColumnKey> columnDefinition) { JdbcColumnKey key = new JdbcColumnKey(column, i); SqlTypeColumnProperty typeColumnProperty = columnDefinition.lookFor(SqlTypeColumnProperty.class); if (typeColumnProperty == null) { ColumnDefinition<JdbcColumnKey, ?> globalDef = mapperConfig.columnDefinitions().getColumnDefinition(key); typeColumnProperty = globalDef.lookFor(SqlTypeColumnProperty.class); } if (typeColumnProperty != null) { return new JdbcColumnKey(key.getName(), key.getIndex(), typeColumnProperty.getSqlType(), key); } return key; }
@Override protected JdbcColumnKey newKey(String column, int i, FieldMapperColumnDefinition<JdbcColumnKey> columnDefinition) { JdbcColumnKey key = new JdbcColumnKey(column, i); SqlTypeColumnProperty typeColumnProperty = columnDefinition.lookFor(SqlTypeColumnProperty.class); if (typeColumnProperty == null) { ColumnDefinition<JdbcColumnKey, ?> globalDef = mapperConfig.columnDefinitions().getColumnDefinition(key); typeColumnProperty = globalDef.lookFor(SqlTypeColumnProperty.class); } if (typeColumnProperty != null) { return new JdbcColumnKey(key.getName(), key.getIndex(), typeColumnProperty.getSqlType(), key); } return key; }
public SqlParameterSourceBuilder<T> add(JdbcColumnKey key, FieldMapperColumnDefinition<JdbcColumnKey> columnDefinition) { final FieldMapperColumnDefinition<JdbcColumnKey> composedDefinition = columnDefinition.compose(mapperConfig.columnDefinitions().getColumnDefinition(key)); final JdbcColumnKey mappedColumnKey = composedDefinition.rename(key); PropertyMapping<T, Object, JdbcColumnKey> propertyMapping; if (composedDefinition.has(ConstantValueProperty.class)) { ConstantValueProperty staticValueProperty = composedDefinition.lookFor(ConstantValueProperty.class); PropertyMeta<T, Object> meta = new ObjectPropertyMeta<T, Object>(key.getName(), builder.getClassMeta().getType(), reflectionService, staticValueProperty.getType(), ScoredGetter.of(new ConstantGetter<T, Object>(staticValueProperty.getValue()), 1), null, null); propertyMapping = builder.addProperty(key, columnDefinition, meta); } else { propertyMapping = builder.addProperty(mappedColumnKey, composedDefinition); } parameters.add(build(key, propertyMapping)); return this; }