hibernate/hibernate-orm · error · IllegalArgumentException
Property not among declared properties: " + property.getName
Error message
Property not among declared properties: " + property.getName()
What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java:1316
public Supplier<? extends Expectation> getUpdateExpectation() {
return updateExpectation;
}
public void setUpdateExpectation(Supplier<? extends Expectation> updateExpectation) {
this.updateExpectation = updateExpectation;
}
public Supplier<? extends Expectation> getDeleteExpectation() {
return deleteExpectation;
}
public void setDeleteExpectation(Supplier<? extends Expectation> deleteExpectation) {
this.deleteExpectation = deleteExpectation;
}
public void removeProperty(Property property) {
if ( !declaredProperties.remove( property ) ) {
throw new IllegalArgumentException( "Property not among declared properties: " + property.getName() );
}
properties.remove( property );
}
public void createConstraints(MetadataBuildingContext context) {
}
}
View on GitHub (pinned to fad1729dce)
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
Example fix
// before rootClass.removeProperty(subclassProperty); // not declared by root // after PersistentClass owner = subclassProperty.getPersistentClass(); owner.removeProperty(subclassProperty);
Defensive patterns
Strategy: validation
Validate before calling
static PersistentClass declaringOwner(PersistentClass start, Property p) {
for (PersistentClass c = start; c != null; c = c.getSuperclass()) {
if (c.getDeclaredProperties().contains(p)) return c;
}
return null; // caller must not invoke removeProperty when null
} Type guard
static boolean isDeclaredOn(PersistentClass pc, Property p) {
return pc != null && pc.getDeclaredProperties().contains(p);
} Prevention
- Always resolve the declaring class before mutating mapping properties
- Treat Hibernate mapping objects as read-only unless you own their lifecycle
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not resolve ServiceRegistry
- Could not find table group for: %s
- removeTableGroupJoin not supported by %s
- Fetch clause may not be null
- Could not resolve NativeQuery parameter type : `%s`
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/f371d6ab9486a4e1.
Report an issue: GitHub.