{"record":{"id":"beb4c453e41b5080","repo":"hibernate/hibernate-orm","slug":"bytecode-enhancement-failed-because-no-public-pro","errorCode":null,"errorMessage":"Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '{}' (private constructors don't work with runtime proxies)","messagePattern":"Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '(.+?)' \\(private constructors don't work with runtime proxies\\)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/pojo/bytebuddy/ByteBuddyProxyFactory.java","lineNumber":106,"sourceCode":"\t\tfinal var hibernateProxy = internal.asHibernateProxy();\n\t\tif ( hibernateProxy == null ) {\n\t\t\tthrow new HibernateException( \"Produced proxy does not correctly implement HibernateProxy\" );\n\t\t}\n\t\treturn hibernateProxy;\n\t}\n\n\t/**\n\t * This technically returns a HibernateProxy, but declaring that type as the return\n\t * type for the newInstance() action triggers an implicit case of type pollution.\n\t * We therefore declare it as PrimeAmongSecondarySupertypes, and require the\n\t * invoker to perform the narrowing\n\t */\n\tprivate PrimeAmongSecondarySupertypes getHibernateProxyInternal() throws HibernateException {\n\t\ttry {\n\t\t\treturn (PrimeAmongSecondarySupertypes) proxyClass.getConstructor().newInstance();\n\t\t}\n\t\tcatch (NoSuchMethodException e) {\n\t\t\tthrow new HibernateException(\n\t\t\t\t\t\"Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '\"\n\t\t\t\t\t\t\t+ entityName + \"' (private constructors don't work with runtime proxies)\", e );\n\t\t}\n\t\tcatch (Throwable t) {\n\t\t\tthrow new HibernateException( \"Bytecode enhancement failed for entity '\" + entityName + \"'\", t );\n\t\t}\n\t}\n\n}\n","sourceCodeStart":88,"sourceCodeEnd":116,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/pojo/bytebuddy/ByteBuddyProxyFactory.java#L88-L116","documentation":"Error \"Bytecode enhancement failed because no public, protected or package-private default constructor was found for entity '{}' (private constructors don't work with runtime proxies)\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A dynamic instantiation (select new) target cannot be constructed.","commonSituations":"Using 'select new SomeClass(...)' where the class is missing or has no matching constructor.","solutions":["Add a public, protected, or package-private no-arg constructor to the entity.","Avoid private-only constructors on entities that need runtime proxies."],"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"}