-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19076 Resolve member of MappedSuperclass specially #10475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds tests and refactors how mapped-superclass members are resolved to address HHH-19076.
- Introduce two new tests (
CompositeInheritanceWorkingTestandCompositeInheritanceFailTest) to illustrate working and failing composite‐ID inheritance cases. - Simplify
resolveMappedSuperclassMemberand add special‐case handling for mapped‐superclass types inidentifierMemberResolverandversionMemberResolverinAttributeFactory. - Remove complex subtype‐inspection logic in favor of a direct getter lookup for mapped‐superclass members.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/composite/CompositeInheritanceWorkingTest.java | New “working” test case for composite‐ID inheritance |
| hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/composite/CompositeInheritanceFailTest.java | New “failing” test case for composite‐ID inheritance |
| hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java | Simplify resolveMappedSuperclassMember and update identifier/version member resolvers to treat mapped‐superclass specially |
Comments suppressed due to low confidence (3)
hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/composite/CompositeInheritanceWorkingTest.java:142
- [nitpick] This method returns the field
otherIdbut is namedmyId(). For clarity and consistency, rename it togetOtherId()or change the field tomyId.
public String myId() {
hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/composite/CompositeInheritanceWorkingTest.java:165
- [nitpick] JavaBean conventions recommend
getOid()instead ofoid(), especially for JPA property access. Consider renaming this getter.
public String oid() {
hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java:785
- The new branch for
MappedSuperclassDomainTypein the identifier resolver is not covered by existing tests. Consider adding a unit test to verify resolution when the owner type is a mapped superclass.
if ( identifiableType instanceof MappedSuperclassDomainType<?> ) {
|
|
||
| } | ||
|
|
||
| public static class CompositeIdClass { |
Copilot
AI
Jul 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the JPA spec, composite‐ID classes must implement equals() and hashCode() to ensure correct identity comparison. Consider adding those methods to CompositeIdClass.
| final Getter getter = getter( declaringEntityMapping, propertyMapping ); | ||
| if ( getter instanceof PropertyAccessMapImpl.GetterImpl ) { | ||
| return new MapMember( identifierMapping.getAttributeName(), identifierMapping.getJavaType().getJavaTypeClass() ); | ||
| if ( identifiableType instanceof MappedSuperclassDomainType<?> ) { |
Copilot
AI
Jul 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The same pattern (propertyMapping.getGetter(...).getMember()) is repeated in both identifier and version resolvers. Consider extracting this into a shared helper to reduce duplication.
[Please describe here what your change is about]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-19076