{"record":{"id":"0184fea00410fb48","repo":"hibernate/hibernate-orm","slug":"return-class-is-required","errorCode":null,"errorMessage":"return class is required","messagePattern":"return class is required","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/id/enhanced/AbstractOptimizer.java","lineNumber":26,"sourceCode":"\n/**\n * Common support for {@link Optimizer} implementations.\n *\n * @author Steve Ebersole\n */\npublic abstract class AbstractOptimizer implements Optimizer {\n\tprotected final Class<?> returnClass;\n\tprotected final int incrementSize;\n\n\t/**\n\t * Construct an optimizer\n\t *\n\t * @param returnClass The expected id class.\n\t * @param incrementSize The increment size\n\t */\n\tAbstractOptimizer(Class<?> returnClass, int incrementSize) {\n\t\tif ( returnClass == null ) {\n\t\t\tthrow new HibernateException( \"return class is required\" );\n\t\t}\n\t\tthis.returnClass = returnClass;\n\t\tthis.incrementSize = incrementSize;\n\t}\n\n\t/**\n\t * Getter for property 'returnClass'.  This is the Java\n\t * class which is used to represent the id (e.g. {@link Long}).\n\t *\n\t * @return Value for property 'returnClass'.\n\t */\n\tpublic final Class<?> getReturnClass() {\n\t\treturn returnClass;\n\t}\n\n\t@Override\n\tpublic final int getIncrementSize() {\n\t\treturn incrementSize;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/id/enhanced/AbstractOptimizer.java#L8-L44","documentation":"Error \"return class is required\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an identifier generator produces or is asked for a Java type it does not support.","commonSituations":"Typical situations: mapping a numeric id to an unsupported type; a UUID generator configured with a non-UUID return type.","solutions":["Specify the id property type (return class) for the optimizer-backed generator in the mapping."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}