HHH-20582 Walk superclass auditing data when resolving @OneToOne mappedBy#12792
HHH-20582 Walk superclass auditing data when resolving @OneToOne mappedBy#12792brodziakm wants to merge 2 commits into
Conversation
mbellade
left a comment
There was a problem hiding this comment.
Thanks @brodziakm, the fix is looking great. I've added a few suggestions on the test side.
There was a problem hiding this comment.
I know you copied this from the "negative" tests of https://github.com/hibernate/hibernate-orm/pull/11175/changes#diff-4133702339842d4a59cbeeb04c398c116f8bd63c758b9a1eb71bb98ded6acc1a, which is fine, but since we expect this case to work correctly it would be better to use the @EnversTest + @Jpa(annotatedClasses={...}) annotations, and actually persist some entities and verify the mappings and audit trail work as expected.
There was a problem hiding this comment.
Please use explicit entity names for inner class entities and avoid GenerationType.IDENTITY as that is not supported across all dbs.
| @Entity(name = "Account") | |
| @Audited | |
| @Inheritance(strategy = InheritanceType.SINGLE_TABLE) | |
| @DiscriminatorColumn(name = "type") | |
| public abstract static class Account { | |
| @Id | |
| @GeneratedValue |
There was a problem hiding this comment.
Same as above:
| @Entity(name = "Credential") | |
| @Audited | |
| @Table(name = "credential") | |
| @Inheritance(strategy = InheritanceType.SINGLE_TABLE) | |
| @DiscriminatorColumn(name = "type") | |
| public abstract static class Credential { | |
| @Id | |
| @GeneratedValue |
There was a problem hiding this comment.
Same as above:
| @Entity(name = "PasswordCredential") |
There was a problem hiding this comment.
Same as above:
| @Entity(name = "User") |
|
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
c731a80 to
95055b0
Compare
95055b0 to
e8b56ee
Compare
|
Thanks @mbellade - I've addressed the PR feedback. Could you take another look when you have a moment? CI may need workflow approval to get further, I'm a first-time contributor. |
e8b56ee to
023d505
Compare
Fixes https://hibernate.atlassian.net/browse/HHH-20582
Envers
ToOneRelationMetadataGenerator.checkMappedByAudited(added in HHH-19897 / PR #11175)validates that the owning side of an inverse
@OneToOneis audited, but only inspects theconcrete referenced entity's
ClassAuditingData.CollectionMappedByResolverwas updated inthe same change to walk superclasses; this brings
@OneToOneinverse resolution in line.Adds
MappedByOnSuperclassOneToOneTestreproducing bootstrap failure whenmappedBytargetsa property declared on a parent
@Entityin aSINGLE_TABLEhierarchy.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.
Please make sure that the following tasks are completed:
Tasks specific to HHH-20582 (Bug):
migration-guide.adocOR check there are no breaking changes