{"record":{"id":"debc2cf4c19a09ce","repo":"apache/shardingsphere","slug":"getobject-with-type","errorCode":null,"errorMessage":"getObject with type","messagePattern":"getObject with type","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java","lineNumber":195,"sourceCode":"    \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\n    public <T> T getObject(final int columnIndex, final Class<T> type) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getObject with type\");\n    }\n    \n    @Override\n    public <T> T getObject(final String columnLabel, final Class<T> type) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getObject with type\");\n    }\n    \n    @Override\n    public final Object getObject(final String columnLabel, final Map<String, Class<?>> map) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getObject with map\");\n    }\n    \n    @Override\n    public final Object getObject(final int columnIndex, final Map<String, Class<?>> map) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getObject with map\");\n    }\n}\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java#L177-L213","documentation":"getObject(int columnIndex, Class<T> type) and its label twin (JDBC 4.1 typed-object accessors) are overridden in AbstractUnsupportedOperationResultSet to throw SQLFeatureNotSupportedException('getObject with type'). The sharding merged ResultSet does not implement the JDBC type-conversion table, so clients must convert fetched values themselves.","triggerScenarios":"Calling rs.getObject(col, MyClass.class) / rs.getObject(\"label\", MyClass.class) on a sharding ResultSet — extremely common in ORM internals (Hibernate/JPA 6.x heavily uses typed getObject), Spring Data JDBC converters, and jOOQ meta-object access.","commonSituations":"Upgrading an ORM version that switched from getObject()+cast to typed getObject; frameworks calling getObject(Integer.class), getObject(LocalDate.class), getObject(UUID.class); migration of working code to the sharding URL where the driver now rejects typed reads.","solutions":["Use the untyped accessor rs.getObject(col) (or the typed getters getString/getInt/getTimestamp/...) and convert in application code (Integer.valueOf, Timestamp.toLocalDateTime, Map.of...).","Add a JDBC-level shim/extendedResultSetClass if your framework allows customizing ResultSet wrapping, mapping typed calls to untyped ones.","Upgrade ShardingSphere — newer driver versions implement several typed-object conversions; verify against your version's release notes before relying on it.","Check whether your ORM has a dialect/setting that avoids JDBC 4.1 typed accessors (e.g. setting that forces legacy object retrieval)."],"exampleFix":"// before\nLocalDate d = rs.getObject(2, LocalDate.class); // throws\n\n// after\nLocalDate d = rs.getDate(2).toLocalDateTime().toLocalDate();\n// or: Object v = rs.getObject(2); then convert explicitly","handlingStrategy":"fallback","validationCode":"Object raw = rs.getObject(col); // untyped read always works\n// convert explicitly per column type","typeGuard":"// prefer explicit typed getters instead of the typed-object accessor\nLocalDate d = rs.getDate(col) == null ? null : rs.getDate(col).toLocalDateTime().toLocalDate();","tryCatchPattern":"try {\n    value = rs.getObject(col, targetType);\n} catch (SQLFeatureNotSupportedException e) {\n    Object raw = rs.getObject(col);\n    value = convert(raw, targetType); // your own converter\n}","preventionTips":["Wrap ResultSet access in a thin adapter that implements typed getObject via untyped reads plus conversion.","Pin and test ORM versions against the ShardingSphere driver — ORM upgrades silently introduce JDBC 4.1 typed accessors.","Check ShardingSphere release notes for added JDBC 4.1 support before upgrading.","Write integration tests that fetch every column type your schema uses through the sharding URL."],"tags":["jdbc","resultset","jdbc41","orm","type-conversion","shardingsphere","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}