{"record":{"id":"651d9b99a63c3eb8","repo":"hibernate/hibernate-orm","slug":"step-parameter-of-function-s-is-of-type-s-651d9b","errorCode":null,"errorMessage":"Step parameter of function '%s()' is of type '%s', but must be of type interval","messagePattern":"Step parameter of function '(.+?)\\(\\)' is of type '(.+?)', but must be of type interval","errorType":"exception","errorClass":"FunctionArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java","lineNumber":100,"sourceCode":"\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()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthrow new FunctionArgumentException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"Unsupported type '%s' for function '%s()'. Only integral, decimal and timestamp types are supported.\",\n\t\t\t\t\t\t\tstartType.getTypeName(),\n\t\t\t\t\t\t\tfunctionName\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/dialect/function/GenerateSeriesArgumentValidator.java#L82-L118","documentation":"For temporal generate_series(start, stop, step) the step must be an interval/duration type (e.g. Hibernate's DurationJavaType / interval literal). Passing a number, string, or timestamp as step throws this FunctionArgumentException naming the actual step type.","triggerScenarios":"generate_series(ts1, ts2, 1), generate_series(:f, :t, :minutes) where :minutes is bound as Integer/String, or copied PostgreSQL SQL where the step is an untyped string '1 hour' that HQL parses as String.","commonSituations":"Porting PostgreSQL generate_series(timestamp, timestamp, interval) but binding the step as an int of seconds or a String; criteria builders supplying a Duration as long milliseconds.","solutions":["Use an interval-typed step: by hours(1), or bind a java.time.Duration parameter so the domain type is a duration","Convert numeric steps: multiply inside the query using duration arithmetic or precompute a Duration in Java","Avoid raw string intervals; HQL needs the interval literal/typed parameter, not '1 hour'::interval text"],"exampleFix":"// before\nsession.createQuery(\"select gs from generate_series(:f, :t, :step) gs\")\n        .setParameter(\"step\", 60); // Integer step -> error\n\n// after\nsession.createQuery(\"select gs from generate_series(:f, :t, :step) gs\")\n        .setParameter(\"step\", Duration.ofMinutes(1)); // duration type","handlingStrategy":"type-guard","validationCode":"if (!(step instanceof java.time.Duration) && isTemporal(start)) {\n    throw new IllegalArgumentException(\"Temporal series step must be a Duration, got \" + step.getClass());\n}","typeGuard":"boolean isIntervalStep(Object step) { return step instanceof Duration; }","tryCatchPattern":null,"preventionTips":["Use java.time.Duration for step parameters; never ints or strings","Use interval literals (by hours(2)) in static HQL","Add a type assertion in repository helpers that wrap generate_series"],"tags":["hibernate","hql","generate-series","interval","type-mismatch"],"backgroundTag":"hql-function-argument-type-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}