{"record":{"id":"91a976cbf1a720f4","repo":"hibernate/hibernate-orm","slug":"support-for-s-was-enabled-during-enhancement-but","errorCode":null,"errorMessage":"Support for %s was enabled during enhancement, but `%s` was previously enhanced with that support %s.","messagePattern":"Support for (.+?) was enabled during enhancement, but `(.+?)` was previously enhanced with that support (.+?)\\.","errorType":"exception","errorClass":"FeatureMismatchException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/FeatureMismatchException.java","lineNumber":61,"sourceCode":"\tpublic String getClassName() {\n\t\treturn className;\n\t}\n\n\tpublic Feature getMismatchedFeature() {\n\t\treturn mismatchedFeature;\n\t}\n\n\tpublic boolean wasPreviouslyEnabled() {\n\t\treturn previousValue;\n\t}\n\n\tpublic static void checkFeatureEnablement(\n\t\t\tTypeDescription managedCtClass,\n\t\t\tFeature feature,\n\t\t\tboolean currentlyEnabled,\n\t\t\tboolean previouslyEnabled) {\n\t\tif ( currentlyEnabled != previouslyEnabled ) {\n\t\t\tthrow new FeatureMismatchException( managedCtClass.getName(), feature, previouslyEnabled );\n\t\t}\n\t}\n\n\tprivate static String featureText(Feature mismatchedFeature) {\n\t\treturn switch ( mismatchedFeature ) {\n\t\t\tcase DIRTY_CHECK -> \"inline dirty checking\";\n\t\t\tcase ASSOCIATION_MANAGEMENT -> \"bidirectional association management\";\n\t\t};\n\t}\n\n\tprivate static String decode(boolean previousValue) {\n\t\treturn previousValue ? \"enabled\" : \"disabled\";\n\t}\n}\n","sourceCodeStart":43,"sourceCodeEnd":76,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/FeatureMismatchException.java#L43-L76","documentation":"FeatureMismatchException.checkFeatureEnablement() compares feature switches recorded in the class's existing EnhancementInfo against the flags of the current EnhancementContext (first inline dirty checking, then association management). If a class was previously enhanced with a feature enabled/disabled and you now re-enhance with the opposite setting, the constructor throws FeatureMismatchException, whose message is built from this template: support was X during enhancement but the class was previously enhanced with it Y.","triggerScenarios":"Re-enhancing already-enhanced classes after changing enhancement options: enabling/disabling 'enableDirtyTracking' (inline dirty checking) or 'enableAssociationManagement' (bidirectional association management) in the plugin or EnhancementContext relative to the run that produced the classes.","commonSituations":"Turning on association management or dirty tracking in a new build while CI/incremental caches hold classes enhanced with the old flags; different teams/modules applying different enhancement flags to shared entities; a build-profile switch (prod vs test) that toggles dirty tracking.","solutions":["Clean-rebuild so enhancement runs on never-enhanced classes with the new, consistent options (mismatch is only checked on re-enhancement).","Keep enhancement flags identical across all builds and modules that touch the same classes - pin them in one shared build config.","Check the exception's feature text ('inline dirty checking' vs 'bidirectional association management') to see exactly which flag flipped, and align it.","If you truly need different modes per environment, do full clean builds per mode instead of re-enhancing cached output."],"exampleFix":"# before\n# CI cache holds classes enhanced with dirtyTracking=false, now building with true\n./gradlew build --build-cache   # -> FeatureMismatchException(DIRTY_CHECK)\n\n# after\n./gradlew clean build --no-build-cache   # enhance pristine classes with current flags\n# and keep the flags fixed in one place:\next { hibernateEnhance { enableDirtyTracking = true; enableAssociationManagement = true } } }","handlingStrategy":"fallback","validationCode":"// pin enhancement flags in one place and record them next to the artifacts\nstatic final boolean ENHANCE_DIRTY_TRACKING = true;\nstatic final boolean ENHANCE_ASSOCIATION_MGMT = false;\n// CI: fail if build flags differ from the recorded ones used for the cached outputs\n","typeGuard":null,"tryCatchPattern":"try { enhanced = enhancer.enhance( className, bytes ); }\ncatch ( FeatureMismatchException e ) {\n    // previous enhancement used different dirty-check/association-management flags\n    cleanOutputsAndRebuild( className ); // re-enhance pristine classes with current, fixed flags\n}","preventionTips":["Declare enhancement options once (shared build convention) and never vary them between profiles or modules touching the same classes.","Disable build caches for enhancement-producing tasks when flags change, or key the cache on the flags.","Read the exception's feature/enablement getters to confirm which flag flipped before rebuilding."],"tags":["hibernate","bytecode-enhancement","configuration-mismatch","build-time"],"backgroundTag":"enhancement-option-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}