{"record":{"id":"ce6bee12dcdf67bb","repo":"hibernate/hibernate-orm","slug":"function-s-requires-exactly-3-arguments-when-in","errorCode":null,"errorMessage":"Function %s() requires exactly 3 arguments when invoked with a temporal argument, but %d arguments given","messagePattern":"Function (.+?)\\(\\) requires exactly 3 arguments when invoked with a temporal argument, but (.+?) arguments given","errorType":"exception","errorClass":"FunctionArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java","lineNumber":86,"sourceCode":"\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,\n\t\t\t\t\t\t\t\targuments.size()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( stepType == null ) {\n\t\t\t\tthrow unknownType( functionName, arguments, 2 );\n\t\t\t}\n\t\t\tfinal var stepJdbcType = ((JdbcMapping) stepType).getJdbcType();\n\t\t\tif ( !stepJdbcType.isInterval() && !stepJdbcType.isDuration() ) {\n\t\t\t\tthrow new FunctionArgumentException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\t\"Step parameter of function '%s()' is of type '%s', but must be of type interval\",\n\t\t\t\t\t\t\t\tfunctionName,\n\t\t\t\t\t\t\t\tstepType.getTypeName()","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java#L68-L104","documentation":"When start/stop are temporal (timestamp/time/date JDBC types), generate_series() has no implicit step: the validator demands a third argument (the step interval) and throws this FunctionArgumentException when only two arguments are given. Numeric series may omit the step, temporal series may not.","triggerScenarios":"HQL 'from generate_series(:from, :to)' where both parameters are LocalDateTime/OffsetDateTime/Date, with no third interval argument; ported PostgreSQL SQL generate_series(ts1, ts2) relying on a default 1-day step, which the emulation does not define.","commonSituations":"Day-range generators (one row per day) written without explicit interval '1 day'; migrating raw SQL to HQL; refactors that dropped the step argument by mistake.","solutions":["Add the explicit interval step: generate_series(:from, :to, by days(1)) / every(1, TimeUnit/jakarta TemporalUnit) per your Hibernate version's interval syntax","Bind the step as a Duration/interval-typed parameter if dynamic","For pure day ranges, generate a numeric series and add days in a select expression: generate_series(0, daysBetween, 1) combined with :from + gs days"],"exampleFix":"// before\nList<LocalDateTime> ds = session.createQuery(\n    \"select gs from generate_series(:f, :t) gs\", LocalDateTime.class)...;\n\n// after\nList<LocalDateTime> ds = session.createQuery(\n    \"select gs from generate_series(:f, :t, by minutes(30)) gs\", LocalDateTime.class)...;","handlingStrategy":"validation","validationCode":"if (isTemporal(start) && step == null) {\n    throw new IllegalArgumentException(\"Temporal generate_series needs an explicit step interval\");\n}\n// then always build: generate_series(:f, :t, by minutes(N))","typeGuard":"boolean isTemporalSeries(Object start) {\n    return start instanceof java.time.temporal.Temporal;\n}","tryCatchPattern":null,"preventionTips":["Make the step argument mandatory in your query-building helper for temporal ranges","Bind steps as java.time.Duration parameters","Port PostgreSQL day-series SQL with an explicit by days(1) step"],"tags":["hibernate","hql","generate-series","temporal","missing-argument"],"backgroundTag":"hql-function-argument-count-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}