{"record":{"id":"f371d6ab9486a4e1","repo":"hibernate/hibernate-orm","slug":"property-not-among-declared-properties-proper","errorCode":null,"errorMessage":"Property not among declared properties: \" + property.getName()","messagePattern":"Property not among declared properties: \" \\+ property\\.getName\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java","lineNumber":1316,"sourceCode":"\tpublic Supplier<? extends Expectation> getUpdateExpectation() {\n\t\treturn updateExpectation;\n\t}\n\n\tpublic void setUpdateExpectation(Supplier<? extends Expectation> updateExpectation) {\n\t\tthis.updateExpectation = updateExpectation;\n\t}\n\n\tpublic Supplier<? extends Expectation> getDeleteExpectation() {\n\t\treturn deleteExpectation;\n\t}\n\n\tpublic void setDeleteExpectation(Supplier<? extends Expectation> deleteExpectation) {\n\t\tthis.deleteExpectation = deleteExpectation;\n\t}\n\n\tpublic void removeProperty(Property property) {\n\t\tif ( !declaredProperties.remove( property ) ) {\n\t\t\tthrow new IllegalArgumentException( \"Property not among declared properties: \" + property.getName() );\n\t\t}\n\t\tproperties.remove( property );\n\t}\n\n\tpublic void createConstraints(MetadataBuildingContext context) {\n\t}\n}\n","sourceCodeStart":1298,"sourceCodeEnd":1324,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java#L1298-L1324","documentation":"removeProperty() was called with a Property that is not among that PersistentClass's declared properties. This IllegalArgumentException guards an internal invariant: a class can only remove properties it declares itself, not inherited ones and not properties belonging to another class. It indicates the caller targeted the wrong PersistentClass.","triggerScenarios":"Calling removeProperty on a subclass for a property declared on its root or @MappedSuperclass; holding two PersistentClass instances and removing from the wrong one; metamodel-manipulation code receiving a Property from another binding.","commonSituations":"Custom enhancement of the Hibernate metamodel between bootstrap phases; test utilities stripping audit or version columns; copy-pasted code operating on the wrong entity class.","solutions":["Locate the declaring class first (walk getSuperclass() and check getDeclaredProperties()), then call removeProperty on it","Use Property.getPersistentClass() when set, to obtain the owning class","Prefer building a filtered mapping over mutating an existing one"],"exampleFix":"// before\nrootClass.removeProperty(subclassProperty); // not declared by root\n\n// after\nPersistentClass owner = subclassProperty.getPersistentClass();\nowner.removeProperty(subclassProperty);","handlingStrategy":"validation","validationCode":"static PersistentClass declaringOwner(PersistentClass start, Property p) {\n    for (PersistentClass c = start; c != null; c = c.getSuperclass()) {\n        if (c.getDeclaredProperties().contains(p)) return c;\n    }\n    return null; // caller must not invoke removeProperty when null\n}","typeGuard":"static boolean isDeclaredOn(PersistentClass pc, Property p) {\n    return pc != null && pc.getDeclaredProperties().contains(p);\n}","tryCatchPattern":null,"preventionTips":["Always resolve the declaring class before mutating mapping properties","Treat Hibernate mapping objects as read-only unless you own their lifecycle"],"tags":["hibernate","orm","internal-api","illegal-argument","metamodel"],"backgroundTag":"illegal-argument","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}