{"record":{"id":"778771883f1563b0","repo":"hibernate/hibernate-orm","slug":"step-parameter-of-function-s-is-of-type-s","errorCode":null,"errorMessage":"Step parameter of function '%s()' is of type '%s', but must be of the same type as start and stop [%s,%s]","messagePattern":"Step parameter of function '(.+?)\\(\\)' is of type '(.+?)', but must be of the same type as start and stop \\[(.+?),(.+?)\\]","errorType":"exception","errorClass":"FunctionArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java","lineNumber":72,"sourceCode":"\t\tif ( startType != stopType ) {\n\t\t\tthrow new FunctionArgumentException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"Start and stop parameters of function '%s()' must be of the same type, but found [%s,%s]\",\n\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t\tstartType.getTypeName(),\n\t\t\t\t\t\t\tstopType.getTypeName()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tfinal var type = (JdbcMapping) startType;\n\t\tfinal var jdbcType = type.getJdbcType();\n\t\tif ( jdbcType.isInteger() || jdbcType.isDecimal() ) {\n\t\t\tif ( step != null ) {\n\t\t\t\tif ( stepType == null ) {\n\t\t\t\t\tthrow unknownType( functionName, arguments, 2 );\n\t\t\t\t}\n\t\t\t\tif ( stepType != startType ) {\n\t\t\t\t\tthrow new FunctionArgumentException(\n\t\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\t\"Step parameter of function '%s()' is of type '%s', but must be of the same type as start and stop [%s,%s]\",\n\t\t\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t\t\t\tstepType.getTypeName(),\n\t\t\t\t\t\t\t\t\tstartType.getTypeName(),\n\t\t\t\t\t\t\t\t\tstopType.getTypeName()\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( jdbcType.isTemporal() ) {\n\t\t\tif ( step == null ) {\n\t\t\t\tthrow new FunctionArgumentException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"Function %s() requires exactly 3 arguments when invoked with a temporal argument, but %d arguments given\",\n\t\t\t\t\t\t\t\tfunctionName,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java#L54-L90","documentation":"For numeric generate_series(start, stop, step) the validator additionally requires step's type to equal start/stop's type exactly (both Integer, both Long, both Double...). A step literal of a different numeric family — classically 1.0 or 1.5 against integer bounds — throws with all three type names listed.","triggerScenarios":"generate_series(1, 10, 1.5) in HQL (Integer bounds, Double step); :step bound as Double while :start/:stop are Integer; mixing Long bounds with Integer step literal.","commonSituations":"Writing a 'every 1.5 units' series without matching bound types; parameter-driven step values defaulting to BigDecimal/Double in the caller; porting PostgreSQL SQL where the DB coerces the step implicitly.","solutions":["Match all three types: generate_series(1.0, 10.0, 1.5) when you need fractional steps","Or keep everything integral: generate_series(1, 10, 2)","Bind the step parameter with the same type class as the bounds: setParameter(\"step\", 1.5, Double.class) with Double bounds"],"exampleFix":"// before\nsession.createQuery(\"select gs from generate_series(1, 10, 0.5) gs\"); // Integer,Integer,Double\n\n// after\nsession.createQuery(\"select gs from generate_series(1.0, 10.0, 0.5) gs\"); // all Double","handlingStrategy":"type-guard","validationCode":"boolean numericStepMatches(Class<?> bound, Class<?> step) { return bound == step; }\n// e.g. reject generate_series(int, int, double) before executing\nif (start instanceof Integer && step instanceof Double) {\n    step = (int) (double) (Double) step; // or promote bounds to Double\n}","typeGuard":"boolean allSameNumericClass(Number a, Number b, Number c) {\n    return a.getClass() == b.getClass() && b.getClass() == c.getClass();\n}","tryCatchPattern":null,"preventionTips":["Pick one numeric family (Integer or Double) for the whole series expression including literals","Bind the step parameter with an explicit type class","Prefer integers when step semantics are whole units; Double for fractional"],"tags":["hibernate","hql","generate-series","type-mismatch","function-validation"],"backgroundTag":"hql-function-argument-type-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}