{"record":{"id":"0d0c7af62c4f2af5","repo":"apache/shardingsphere","slug":"getref","errorCode":null,"errorMessage":"getRef","messagePattern":"getRef","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java","lineNumber":175,"sourceCode":"    \n    @Override\n    public final NClob getNClob(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNClob\");\n    }\n    \n    @Override\n    public final Reader getNCharacterStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNCharacterStream\");\n    }\n    \n    @Override\n    public final Reader getNCharacterStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNCharacterStream\");\n    }\n    \n    @Override\n    public final Ref getRef(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getRef\");\n    }\n    \n    @Override\n    public final Ref getRef(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getRef\");\n    }\n    \n    @Override\n    public final RowId getRowId(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getRowId\");\n    }\n    \n    @Override\n    public final RowId getRowId(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getRowId\");\n    }\n    \n    @Override","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java#L157-L193","documentation":"getRef(int columnIndex) is final in AbstractUnsupportedOperationResultSet and unconditionally throws SQLFeatureNotSupportedException. SQL REF types are structured-type references that the sharding driver cannot resolve across shards, so the accessor is disabled even when the underlying database supports REF columns.","triggerScenarios":"Calling ResultSet.getRef(columnIndex) on a ResultSet from ShardingSphereDataSource — usually generic type-dispatch mappers that handle java.sql.Types.REF, or code ported from object-relational schemas (Oracle REF, SQL:1999 structured types).","commonSituations":"Object-relational database features used behind the sharding layer; row mappers with exhaustive Types switches that call getRef for REF columns; migration from drivers where REF columns return java.sql.Ref.","solutions":["Fetch the reference as its underlying representation: getObject(columnIndex) or getString(columnIndex), and dereference manually with a keyed SELECT on the target table.","Model the relationship with ordinary foreign-key columns plus JOIN queries instead of SQL REFs when sharding.","Remove/guard the getRef branch in type-dispatch code when running under ShardingSphere."],"exampleFix":"// before\nRef ref = rs.getRef(4); // throws\nObject target = ref.getObject();\n\n// after\nObject refKey = rs.getObject(4);\n// then: SELECT ... FROM target_table WHERE id = ?","handlingStrategy":"try-catch","validationCode":"int type = rs.getMetaData().getColumnType(col);\nif (type == Types.REF) { Object key = rs.getObject(col); /* deref manually */ }","typeGuard":"boolean isRefColumn(ResultSetMetaData md, int col) throws SQLException {\n    return md.getColumnType(col) == Types.REF;\n}","tryCatchPattern":"try {\n    ref = rs.getRef(col);\n} catch (SQLFeatureNotSupportedException e) {\n    Object key = rs.getObject(col);\n    target = fetchByKey(conn, key);\n}","preventionTips":["Avoid SQL REF/structured types in schemas that sit behind sharding.","Model references as FK columns plus JOINs.","Dereference references manually with keyed SELECTs."],"tags":["jdbc","resultset","ref","object-relational","shardingsphere","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}