{"record":{"id":"5f2f14928f7fcf69","repo":"hibernate/hibernate-orm","slug":"dialect-procedurecall-getsession-getjdbcser-5f2f14","errorCode":null,"errorMessage":"Dialect [\" + procedureCall.getSession().getJdbcServices().getJdbcEnvironment().getDialect().getClass().getName() + \"] not known to support REF_CURSOR parameters","messagePattern":"Dialect \\[\" \\+ procedureCall\\.getSession\\(\\)\\.getJdbcServices\\(\\)\\.getJdbcEnvironment\\(\\)\\.getDialect\\(\\)\\.getClass\\(\\)\\.getName\\(\\) \\+ \"\\] not known to support REF_CURSOR parameters","errorType":"exception","errorClass":"QueryException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/procedure/internal/SybaseCallableStatementSupport.java","lineNumber":75,"sourceCode":"\t\t\t\t\t.append( FUNCTION_SYNTAX_START );\n\t\t}\n\t\telse {\n\t\t\toffset = 1;\n\t\t\tbuffer = new StringBuilder( CALL_SYNTAX_START.length() + CALL_SYNTAX_END.length() + procedureName.length() + paramStringSizeEstimate )\n\t\t\t\t\t.append( CALL_SYNTAX_START );\n\t\t}\n\n\t\tbuffer.append( procedureName );\n\n\t\tif ( registrations.isEmpty() ) {\n\t\t\tbuffer.append( '(' );\n\t\t}\n\t\telse {\n\t\t\tchar sep = '(';\n\t\t\tfor ( int i = 0; i < registrations.size(); i++ ) {\n\t\t\t\tfinal ProcedureParameterImplementor<?> parameter = registrations.get( i );\n\t\t\t\tif ( parameter.getMode() == ParameterMode.REF_CURSOR ) {\n\t\t\t\t\tthrow new QueryException( \"Dialect [\" + procedureCall.getSession().getJdbcServices().getJdbcEnvironment().getDialect().getClass().getName() + \"] not known to support REF_CURSOR parameters\" );\n\t\t\t\t}\n\t\t\t\tbuffer.append( sep );\n\t\t\t\tfinal JdbcCallParameterRegistration registration = parameter.toJdbcParameterRegistration(\n\t\t\t\t\t\ti + offset,\n\t\t\t\t\t\tprocedureCall\n\t\t\t\t);\n\t\t\t\tfinal SharedSessionContractImplementor session = procedureCall.getSession();\n\t\t\t\tif (  parameter.getName() != null\n\t\t\t\t\t\t&& session.getJdbcServices().getExtractedMetaDataSupport().supportsNamedParameters()\n\t\t\t\t\t\t&& session.getFactory().getSessionFactoryOptions().isPassProcedureParameterNames()  ) {\n\t\t\t\t\tbuffer.append(\"@\").append( parameter.getName() ).append( \" = ?\" );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbuffer.append( \"?\" );\n\t\t\t\t}\n\t\t\t\tsep = ',';\n\t\t\t\tbuilder.addParameterRegistration( registration );\n\t\t\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/procedure/internal/SybaseCallableStatementSupport.java#L57-L93","documentation":"SybaseCallableStatementSupport renders the call string parameter-by-parameter and throws QueryException the instant it encounters a ParameterMode.REF_CURSOR registration, resolving the dialect name from procedureCall.getSession().getJdbcServices().getJdbcEnvironment().getDialect(). Sybase ASE has no REF_CURSOR parameter type; procedures there return result sets implicitly.","triggerScenarios":"Any ParameterMode.REF_CURSOR registration on a session whose dialect resolves to a Sybase dialect — thrown while building the {call ...} string, before execution. The name check runs per registration inside the rendering loop.","commonSituations":"Shared stored-procedure code run against multiple databases where one target is Sybase ASE; migrations onto Sybase; test matrices where one node uses jConnect/jTDS with Sybase dialect resolution.","solutions":["Drop the REF_CURSOR registration on Sybase and read the implicit result sets via getResults()/getResultList()","Branch on dialect.supportsRefCursors() (it is false for Sybase) so Sybase uses a cursorless code path","Wrap the Sybase procedure so it SELECTs rows back instead of opening a cursor parameter"],"exampleFix":"// before\ncall.registerParameter(1, void.class, ParameterMode.REF_CURSOR); // Sybase: unsupported\n\n// after\nProcedureOutputs outputs = call.execute();\nList<?> orders = outputs.getResultList(); // implicit result set on Sybase","handlingStrategy":"validation","validationCode":"Dialect dialect = session.getJdbcServices().getJdbcEnvironment().getDialect();\nboolean sybasePath = !dialect.supportsRefCursors(); // Sybase ASE: false\n// if (sybasePath) do not register ParameterMode.REF_CURSOR at all","typeGuard":null,"tryCatchPattern":"try {\n    call.execute();\n} catch (org.hibernate.QueryException e) {\n    if (e.getMessage().contains(\"REF_CURSOR\")) {\n        // Sybase path: remove REF_CURSOR registration, read result sets via getResults()\n    }\n}","preventionTips":["Branch procedure code on dialect.supportsRefCursors() when Sybase is a target","On Sybase, always rely on implicit result sets instead of cursor parameters","Include a Sybase profile in the CI matrix for shared procedure code"],"tags":["hibernate","stored-procedure","ref-cursor","sybase","dialect"],"backgroundTag":"ref-cursor-unsupported","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}