{"record":{"id":"2c93abe4c1fb354d","repo":"quarkusio/quarkus","slug":"failed-to-generate-enhanced-proxy-default-constru","errorCode":null,"errorMessage":"Failed to generate Enhanced Proxy: default constructor is missing for entity '<entityName>'. Please add a default constructor explicitly.","messagePattern":"Failed to generate Enhanced Proxy: default constructor is missing for entity '<entityName>'\\. Please add a default constructor explicitly\\.","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java","lineNumber":59,"sourceCode":"        this.proxyDefinitionMap = proxyDefinitionMap;\n    }\n\n    public static ProxyDefinitions createFromMetadata(Metadata storeableMetadata, PreGeneratedProxies preGeneratedProxies) {\n        if (needAnyProxyDefinitions(storeableMetadata)) {\n            final HashMap<Class<?>, ProxyClassDetailsHolder> proxyDefinitionMap = new HashMap<>();\n            for (PersistentClass persistentClass : storeableMetadata.getEntityBindings()) {\n                if (needsProxyGeneration(persistentClass)) {\n                    final Class<?> mappedClass = persistentClass.getMappedClass();\n                    final Class<?> proxyClassDefinition = getProxyClass(persistentClass, preGeneratedProxies);\n                    if (proxyClassDefinition == null) {\n                        continue;\n                    }\n                    final boolean overridesEquals = ReflectHelper.overridesEquals(mappedClass);\n                    try {\n                        proxyDefinitionMap.put(mappedClass,\n                                new ProxyClassDetailsHolder(overridesEquals, proxyClassDefinition.getConstructor()));\n                    } catch (NoSuchMethodException e) {\n                        throw new HibernateException(\n                                \"Failed to generate Enhanced Proxy: default constructor is missing for entity '\"\n                                        + mappedClass.getName() + \"'. Please add a default constructor explicitly.\");\n                    }\n                }\n            }\n            return new ProxyDefinitions(proxyDefinitionMap);\n        } else {\n            return new ProxyDefinitions(Collections.emptyMap());\n        }\n    }\n\n    private static boolean needAnyProxyDefinitions(Metadata storeableMetadata) {\n        for (PersistentClass persistentClass : storeableMetadata.getEntityBindings()) {\n            if (needsProxyGeneration(persistentClass))\n                return true;\n        }\n        return false;\n    }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java#L41-L77","documentation":"Quarkus builds lazy-loading proxies for Hibernate entities ahead of time (no runtime bytecode generation in native). ProxyDefinitions.createFromMetadata tries to fetch the proxy constructor, which requires the entity class to have an accessible no-arg constructor; when the entity only has parameterized constructors, getting the constructor throws NoSuchMethodException, rethrown as this HibernateException.","triggerScenarios":"An @Entity class (used as a lazy-association target or with lazy loading) declares only constructors with parameters and no explicit no-arg constructor; during SessionFactory creation Quarkus runs proxyDefinitions creation from the Hibernate metamodel and fails at getConstructor().","commonSituations":"Modern entity design with @Id and convenience constructors plus a parametrized constructor, forgetting JPA's requirement of a public/protected no-arg constructor; Lombok @Builder/@AllArgsConstructor without @NoArgsConstructor; entities introduced from other frameworks' codebases.","solutions":["Add a public (or protected) no-argument constructor to the entity named in the message.","If using Lombok, annotate the entity with @NoArgsConstructor and keep @AllArgsConstructor/@Builder if needed.","Check every lazy association target of that entity — the entity name in the message is the one missing the constructor."],"exampleFix":"// before\n@Entity\npublic class Book {\n    private String title;\n    public Book(String title) { this.title = title; }\n}\n\n// after\n@Entity\npublic class Book {\n    protected Book() {} // for Hibernate proxying\n    public Book(String title) { this.title = title; }\n}","handlingStrategy":"validation","validationCode":"// Check every @Entity has a no-arg constructor before startup\nfor (Class<?> e : entityClasses) {\n    boolean hasNoArgCtor = Arrays.stream(e.getDeclaredConstructors())\n        .anyMatch(c -> c.getParameterCount() == 0\n            && (Modifier.isPublic(c.getModifiers()) || Modifier.isProtected(c.getModifiers())));\n    if (!hasNoArgCtor) throw new IllegalStateException(\"Entity missing no-arg ctor: \" + e.getName());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always add a protected no-arg constructor to @Entity classes","With Lombok, pair @Builder/@AllArgsConstructor with @NoArgsConstructor","Remember JPA spec requires a public or protected no-arg constructor on entities"],"tags":["hibernate-orm","jpa","proxy","entity","constructor"],"backgroundTag":"missing-default-constructor","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}