@Override protected String getArrayComponentTypeName(AttributeDescriptor att) throws SQLException { if (att == null) { return null; } String name = (String) att.getUserData().get(JDBCDataStore.JDBC_NATIVE_TYPENAME); // in postgresql jdbc the database metadata TYPE_NAME column contains the // array "base type" name, prefixed with an underscore if (name != null && name.startsWith("_")) { return name.substring(1); } return super.getArrayComponentTypeName(att); }
/** * Sets a value in a prepared statement, for the specific case of {@link Array} * * <p>This method uses the standard SQL Array handling, subclasses can override to add special * behavior * * @param value the value. * @param att The full attribute description * @param ps The prepared statement. * @param column The column the value maps to. * @param cx The database connection. * @throws SQLException */ public void setArrayValue( Object value, AttributeDescriptor att, PreparedStatement ps, int i, Connection cx) throws SQLException { if (value == null) { ps.setNull(i, Types.ARRAY); } else { String typeName = getArrayComponentTypeName(att); Class<?> componentType = typeName != null ? dataStore.getSqlTypeNameToClassMappings().get(typeName) : String.class; Array array = convertToArray(value, typeName, componentType, cx); ps.setArray(i, array); } }