-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Envers - Proposal fix for HHH-4646 and HHH-5177 #3
Conversation
Deleting obsolete tests
added methods isEmpty() and contains(key)
- Read audited properties from subclasses first, then check recursively on superclasses. - Chech on superclasses only if a class is audited - Calculate if the "current" class of the recursion is audited at class level. - Created ComponentAuditedPropertiesReader subclass for AuditedPropertiesReader to use for reading component audited properties inside classes - Created a protected method in AuditedPropertiesReader, letting the subclass do their job. - Ordered the code to be more understandable.
Adding tests cases: - MappedSuperclass audited at class level with a NotAuditedSubclass and: - Audited subclass at class level - Audited subclass at method/field level - MappedSuperclass audited at method/field level with a NotAuditedSubclass and: - Audited subclass at class level - Audited subclass at method/field level
I looked at the patch and I've got one question: why do the the methods addPropertiesFromClass and addPropertiesFromClassRec differ? Shouldn't properties be always read first, and then superclasses? |
Oh yes! You're right. The method addPropertiesFromClassRec must be:
|
So then the addPropertiesFromClassRec method can be removed compeltely. Trying :) |
Yes! sorry for that mistake. |
Pushed into 3.6 |
Merging these changes to the master branch isn't that easy. If you've got an idea on how to do it, let me know :) |
What's the problem? Is there a refactor or something on sources on master? |
Yes, the modules are renamed from envers to hibernate-envers. In fact I'm looking for a generic solution on how to merge some commits from 3.6 to master. So if you find a way, please share :) |
Oh! I see... All modules were renamed, so it's an issue for all components. |
I think it would be the same - the problem is that git doesn't recognize the rename. I'm planning on creating a create patch - rename paths with sed - apply patch script which takes git commit hashes, but didn't have time yet ;) |
…lizedAssociationTest This test accesses a field of an entity directly and expects it to be automatically initialized; this cannot work without extended bytecode enhancement. This used to work with Java 8 bytecode, but only by chance. It seems that Java 8 bytecode relies on "synthetic", static access methods inserted by the compiler to access the fields of entities in this test: any access to the field is done through this access method instead of through a direct field access. Since we apply bytecode enhancement to all methods of entities, this means that access to fields triggers initialization, without any bytecode enhancement in the caller class. I believe this is specific to nested classes, but couldn't find a source. For reference, the bytecode of access methods looks like this: static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int); Code: 0: aload_0 1: iload_1 2: dup_x1 3: putfield hibernate#3 // Field id:I 6: ireturn static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId); Code: 0: aload_0 1: aload_1 2: dup_x1 3: putfield hibernate#2 // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId; 6: areturn With Java 11, however, access to fields of entities is done directly, even for nested classes. So the access methods no longer exist, and we don't get automatic initialization upon field access. We need extended bytecode enhancement, like we would in any other case of field access (in particular accessing fields of non-nested classes).
…lizedAssociationTest This test accesses a field of an entity directly and expects it to be automatically initialized; this cannot work without extended bytecode enhancement. This used to work with Java 8 bytecode, but only by chance. It seems that Java 8 bytecode relies on "synthetic", static access methods inserted by the compiler to access the fields of entities in this test: any access to the field is done through this access method instead of through a direct field access. Since we apply bytecode enhancement to all methods of entities, this means that access to fields triggers initialization, without any bytecode enhancement in the caller class. I believe this is specific to nested classes, but couldn't find a source. For reference, the bytecode of access methods looks like this: static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int); Code: 0: aload_0 1: iload_1 2: dup_x1 3: putfield #3 // Field id:I 6: ireturn static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId); Code: 0: aload_0 1: aload_1 2: dup_x1 3: putfield #2 // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId; 6: areturn With Java 11, however, access to fields of entities is done directly, even for nested classes. So the access methods no longer exist, and we don't get automatic initialization upon field access. We need extended bytecode enhancement, like we would in any other case of field access (in particular accessing fields of non-nested classes).
…lizedAssociationTest This test accesses a field of an entity directly and expects it to be automatically initialized; this cannot work without extended bytecode enhancement. This used to work with Java 8 bytecode, but only by chance. It seems that Java 8 bytecode relies on "synthetic", static access methods inserted by the compiler to access the fields of entities in this test: any access to the field is done through this access method instead of through a direct field access. Since we apply bytecode enhancement to all methods of entities, this means that access to fields triggers initialization, without any bytecode enhancement in the caller class. I believe this is specific to nested classes, but couldn't find a source. For reference, the bytecode of access methods looks like this: static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int); Code: 0: aload_0 1: iload_1 2: dup_x1 3: putfield hibernate#3 // Field id:I 6: ireturn static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId); Code: 0: aload_0 1: aload_1 2: dup_x1 3: putfield hibernate#2 // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId; 6: areturn With Java 11, however, access to fields of entities is done directly, even for nested classes. So the access methods no longer exist, and we don't get automatic initialization upon field access. We need extended bytecode enhancement, like we would in any other case of field access (in particular accessing fields of non-nested classes).
…lizedAssociationTest This test accesses a field of an entity directly and expects it to be automatically initialized; this cannot work without extended bytecode enhancement. This used to work with Java 8 bytecode, but only by chance. It seems that Java 8 bytecode relies on "synthetic", static access methods inserted by the compiler to access the fields of entities in this test: any access to the field is done through this access method instead of through a direct field access. Since we apply bytecode enhancement to all methods of entities, this means that access to fields triggers initialization, without any bytecode enhancement in the caller class. I believe this is specific to nested classes, but couldn't find a source. For reference, the bytecode of access methods looks like this: static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int); Code: 0: aload_0 1: iload_1 2: dup_x1 3: putfield hibernate#3 // Field id:I 6: ireturn static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId); Code: 0: aload_0 1: aload_1 2: dup_x1 3: putfield hibernate#2 // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId; 6: areturn With Java 11, however, access to fields of entities is done directly, even for nested classes. So the access methods no longer exist, and we don't get automatic initialization upon field access. We need extended bytecode enhancement, like we would in any other case of field access (in particular accessing fields of non-nested classes).
…lizedAssociationTest This test accesses a field of an entity directly and expects it to be automatically initialized; this cannot work without extended bytecode enhancement. This used to work with Java 8 bytecode, but only by chance. It seems that Java 8 bytecode relies on "synthetic", static access methods inserted by the compiler to access the fields of entities in this test: any access to the field is done through this access method instead of through a direct field access. Since we apply bytecode enhancement to all methods of entities, this means that access to fields triggers initialization, without any bytecode enhancement in the caller class. I believe this is specific to nested classes, but couldn't find a source. For reference, the bytecode of access methods looks like this: static int access$002(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, int); Code: 0: aload_0 1: iload_1 2: dup_x1 3: putfield #3 // Field id:I 6: ireturn static org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId access$102(org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$AnEntity, org.hibernate.test.bytecode.enhancement.lazy.NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId); Code: 0: aload_0 1: aload_1 2: dup_x1 3: putfield #2 // Field entityImmutableNaturalId:Lorg/hibernate/test/bytecode/enhancement/lazy/NaturalIdInUninitializedAssociationTest$EntityImmutableNaturalId; 6: areturn With Java 11, however, access to fields of entities is done directly, even for nested classes. So the access methods no longer exist, and we don't get automatic initialization upon field access. We need extended bytecode enhancement, like we would in any other case of field access (in particular accessing fields of non-nested classes). (cherry picked from commit 1060baf)
Hi!
It's my first pull request. I hope to be doing well.
As I mencioned on envers forum I've been working on this issuues.
Regards. Hernán.