{"record":{"id":"c6938c047768f2b4","repo":"apache/shardingsphere","slug":"setref","errorCode":null,"errorMessage":"setRef","messagePattern":"setRef","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationPreparedStatement.java","lineNumber":84,"sourceCode":"    \n    @Override\n    public final void setNCharacterStream(final int parameterIndex, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNCharacterStream\");\n    }\n    \n    @Override\n    public final void setNCharacterStream(final int parameterIndex, final Reader x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNCharacterStream\");\n    }\n    \n    @Override\n    public final void setRowId(final int parameterIndex, final RowId x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setRowId\");\n    }\n    \n    @Override\n    public final void setRef(final int parameterIndex, final Ref x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setRef\");\n    }\n    \n    @Override\n    public final ResultSet executeQuery(final String sql) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"executeQuery with SQL for PreparedStatement\");\n    }\n    \n    @Override\n    public final int executeUpdate(final String sql) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"executeUpdate with SQL for PreparedStatement\");\n    }\n    \n    @Override\n    public final int executeUpdate(final String sql, final int autoGeneratedKeys) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"executeUpdate with SQL for PreparedStatement\");\n    }\n    \n    @Override","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationPreparedStatement.java#L66-L102","documentation":"SQLFeatureNotSupportedException('setRef') thrown by AbstractUnsupportedOperationPreparedStatement.setRef(int, Ref). SQL REF columns (references to structured SQL3 types) are essentially unimplemented across mainstream databases and cannot be re-bound by ShardingSphere's pipeline, so the final override always throws.","triggerScenarios":"ps.setRef(1, ref) on a ShardingSphere PreparedStatement; only reachable through code explicitly handling java.sql.Ref — generic framework dispatch or legacy SQL3-era database code.","commonSituations":"Porting ancient SQL3/Object-Relational code paths; coverage-completeness wrappers that implement every PreparedStatement setter; almost never seen with real MySQL/PostgreSQL/OpenGauss schemas.","solutions":["Model the relationship with an ordinary foreign-key column and bind its value (setLong/setString) instead of a REF.","Delete the setRef branch from generic binders — no mainstream backend path through ShardingSphere supports it.","If REF semantics are truly required, bypass the sharded datasource for that specific operation."],"exampleFix":"// before\nps.setRef(1, ref);\n\n// after\nps.setLong(1, targetId); // store the referenced object's key","handlingStrategy":"fallback","validationCode":"if (value instanceof Ref) { throw new IllegalArgumentException(\"SQL REF unsupported; bind the referenced key instead\"); } else { ps.setObject(idx, value); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model references as foreign-key values, not java.sql.Ref","Remove REF branches from generic binders","Keep SQL3 object-relational features off sharded paths"],"tags":["jdbc","shardingsphere","preparedstatement","ref","sql3","sql-feature-not-supported"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}