{"record":{"id":"7c282afcc8b652a4","repo":"hibernate/hibernate-orm","slug":"jdbc-driver-does-not-support-named-parameters-for-7c282a","errorCode":null,"errorMessage":"JDBC driver does not support named parameters for setArray. Use positional.","messagePattern":"JDBC driver does not support named parameters for setArray\\. Use positional\\.","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/type/OracleArrayJdbcType.java","lineNumber":116,"sourceCode":"\t\t@Override\n\t\tprotected void doBindNull(CallableStatement st, String name, WrapperOptions options) throws SQLException {\n\t\t\tst.setNull( name, ARRAY, typeName( options ) );\n\t\t}\n\n\t\t@Override\n\t\tprotected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {\n\t\t\tst.setArray( index, getBindValue( value, options ) );\n\t\t}\n\n\t\t@Override\n\t\tprotected void doBind(CallableStatement st, X value, String name, WrapperOptions options)\n\t\t\t\tthrows SQLException {\n\t\t\tfinal java.sql.Array arr = getBindValue( value, options );\n\t\t\ttry {\n\t\t\t\tst.setObject( name, arr, ARRAY );\n\t\t\t}\n\t\t\tcatch (SQLException ex) {\n\t\t\t\tthrow new HibernateException( \"JDBC driver does not support named parameters for setArray. Use positional.\", ex );\n\t\t\t}\n\t\t}\n\n\t\t@Override\n\t\tpublic java.sql.Array getBindValue(X value, WrapperOptions options) throws SQLException {\n\t\t\tfinal var elementBinder = getElementJdbcType().getBinder( pluralJavaType.getElementJavaType() );\n\t\t\tfinal var objects = convertToArray( this, elementBinder, pluralJavaType, value, options );\n\t\t\tfinal String arrayTypeName = typeName( options );\n\t\t\tfinal var oracleConnection =\n\t\t\t\t\toptions.getSession().getJdbcCoordinator().getLogicalConnection().getPhysicalConnection()\n\t\t\t\t\t\t\t.unwrap( OracleConnection.class );\n\t\t\ttry {\n\t\t\t\treturn oracleConnection.createOracleArray( arrayTypeName, objects );\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new HibernateException( \"Couldn't create a java.sql.Array\", e );\n\t\t\t}\n\t\t}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/type/OracleArrayJdbcType.java#L98-L134","documentation":"Binding an Oracle array (VARRAY / nested table) mapped with OracleArrayJdbcType to a stored-procedure call by parameter NAME: Hibernate falls back to CallableStatement.setObject(name, array, Types.ARRAY), and when the Oracle driver rejects named binding for array values the SQLException is wrapped in this HibernateException. It is a driver capability gap, not a data problem - the identical bind succeeds positionally via PreparedStatement.setArray.","triggerScenarios":"Calling a stored procedure through StoredProcedureQuery, @ProcedureCall, or createStoredProcedureQuery where an IN parameter is an Oracle collection type (VARRAY/nested table) mapped with OracleArrayJdbcType, and the parameter is bound by name (setParameter(\"p_ids\", list) on a named-parameter registration). The driver throws on setObject(name, ...), which Hibernate wraps.","commonSituations":"Migrating Hibernate 5 StoredProcedureCall code to Hibernate 6 mappings that route through OracleArrayJdbcType; legacy PL/SQL APIs that accept VARRAY inputs; older ojdbc versions with narrower named-parameter support.","solutions":["Switch the procedure call to positional parameter binding (registerParameter(1, ...) / positional ?): setArray-based positional binding is the supported path.","Upgrade the Oracle JDBC driver (ojdbc11/ojdbc8 recent versions) and retest - named-bind support varies by driver release.","If positional is impossible, bypass JPA binding with session.doReturningWork and call oracleConnection.createOracleArray yourself with a positional ?.","Change the PL/SQL signature to accept a delimited string or use a global temporary table instead of a collection parameter."],"exampleFix":"// before - named parameter, fails on Oracle\nStoredProcedureQuery q = em.createStoredProcedureQuery(\"MY_PKG.TAKE_IDS\");\nq.registerStoredProcedureParameter(\"p_ids\", Object[].class, ParameterMode.IN);\nq.setParameter(\"p_ids\", ids);\n// after - positional parameter, uses setArray\nStoredProcedureQuery q = em.createStoredProcedureQuery(\"MY_PKG.TAKE_IDS\");\nq.registerStoredProcedureParameter(1, Object[].class, ParameterMode.IN);\nq.setParameter(1, ids);","handlingStrategy":"fallback","validationCode":"// Prefer positional binding whenever the procedure takes non-scalar Oracle types\nint parameters = 1; // use registerStoredProcedureParameter(1, ...) instead of named registration","typeGuard":null,"tryCatchPattern":"try {\n    query.setParameter(\"p_arr\", list);            // named bind\n} catch (HibernateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"named parameters for setArray\")) {\n        query.setParameter(1, list);              // fall back to positional bind\n    } else throw e;\n}","preventionTips":["Standardize on positional parameters for all stored-procedure calls that bind arrays or structured types.","Wrap procedure calls in a repository layer so the binding strategy is fixed in one place.","Pin a known-good ojdbc version and record it in the project docs."],"tags":["oracle","stored-procedure","array","named-parameters","callablestatement","jdbc"],"backgroundTag":"stored-procedure-parameter-binding","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}