{"record":{"id":"80849b5bfab47ed6","repo":"hibernate/hibernate-orm","slug":"jdbc-driver-does-not-support-named-parameters-for-80849b","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/PostgreSQLArrayJdbcType.java","lineNumber":58,"sourceCode":"\t\tprivate Binder(JavaType<X> javaType, BasicPluralJavaType<E> pluralJavaType) {\n\t\t\tsuper( javaType, PostgreSQLArrayJdbcType.this );\n\t\t\tthis.pluralJavaType = pluralJavaType;\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, getArray( 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 = getArray( value, options );\n\t\t\ttry {\n\t\t\t\tst.setObject( name, arr, java.sql.Types.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 Object[] getBindValue(X value, WrapperOptions options) throws SQLException {\n\t\t\tfinal var elementBinder = getElementJdbcType().getBinder( pluralJavaType.getElementJavaType() );\n\t\t\treturn convertToArray( this, elementBinder, pluralJavaType, value, options );\n\t\t}\n\n\t\tprivate java.sql.Array getArray(X value, WrapperOptions options) throws SQLException {\n\t\t\tfinal var session = options.getSession();\n\t\t\treturn session.getJdbcCoordinator().getLogicalConnection().getPhysicalConnection()\n\t\t\t\t\t.createArrayOf( getElementTypeName( getJavaType(), session ),\n\t\t\t\t\t\t\telements( value, options, PostgreSQLArrayJdbcType.this ) );\n\t\t}\n\n\t\tprivate Object[] elements(X value, WrapperOptions options, PostgreSQLArrayJdbcType arrayJdbcType)\n\t\t\t\tthrows SQLException {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/type/PostgreSQLArrayJdbcType.java#L40-L76","documentation":"Binding a PostgreSQL array to a stored-procedure call by parameter name: PostgreSQLArrayJdbcType first binds positionally via setArray, but for named CallableStatement parameters it must use setObject(name, array, Types.ARRAY). PgJDBC does not support named parameters on CallableStatement, so the driver throws and Hibernate wraps it with this message. The array mapping itself is fine - the named-parameter bind path is the unsupported part.","triggerScenarios":"StoredProcedureQuery / @ProcedureCall against PostgreSQL with a named IN parameter bound to an array-mapped attribute (e.g. setParameter(\"p_ids\", list) where the parameter is a text[]/int[] type). The PgJDBC call setObject(name, ...) fails and this exception is thrown at bind time.","commonSituations":"Calling PL/pgSQL functions taking VARIADIC or array parameters through JPA named parameters; porting Oracle-style named procedure calls to PostgreSQL; older PgJDBC versions with no partial named-parameter support.","solutions":["Use positional parameter binding for the procedure call (registerStoredProcedureParameter(1, ...) and setParameter(1, ...)).","Rewrite the call as a native query with ? placeholders and setParameter(int, Object[]) so the driver builds the array.","Upgrade PgJDBC and retest if you must keep named parameters.","Change the function signature to accept a comma-separated string (string_to_array inside the function) instead of an array parameter."],"exampleFix":"// before - named parameter, PgJDBC rejects it\nStoredProcedureQuery q = em.createStoredProcedureQuery(\"take_ids(text[])\");\nq.registerStoredProcedureParameter(\"p_ids\", Object[].class, ParameterMode.IN);\nq.setParameter(\"p_ids\", ids);\n// after - positional binding via setArray path\nStoredProcedureQuery q = em.createStoredProcedureQuery(\"take_ids(text[])\");\nq.registerStoredProcedureParameter(1, Object[].class, ParameterMode.IN);\nq.setParameter(1, ids);","handlingStrategy":"fallback","validationCode":"// Detect PgJDBC before relying on named array binds\nString url = dataSource.getConnection().getMetaData().getURL();\nboolean isPg = url.startsWith(\"jdbc:postgresql:\");\n// if isPg -> register procedure parameters positionally from the start","typeGuard":null,"tryCatchPattern":"try {\n    query.setParameter(\"p_ids\", ids); // named\n} catch (HibernateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"named parameters for setArray\")) {\n        query.setParameter(1, ids);   // PgJDBC: positional only\n    } else throw e;\n}","preventionTips":["Use positional ? parameters for every PostgreSQL function call that takes arrays.","Prefer native queries with typed parameter binding for array-returning/accepting functions.","Track PgJDBC named-parameter support in your pinned driver version before writing named calls."],"tags":["postgresql","stored-procedure","array","named-parameters","pgjdbc","callablestatement"],"backgroundTag":"stored-procedure-parameter-binding","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}