[Hibernate-JIRA] Created: (HHH-3744) Improved support for persistence of subclasses
by Ben Clark (JIRA)
Improved support for persistence of subclasses
----------------------------------------------
Key: HHH-3744
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3744
Project: Hibernate Core
Issue Type: Patch
Components: envers
Environment: hibernate-envers-3.4.0-SNAPSHOT, hibernate-core-3.4.0-SNAPSHOT, hibernate-annotations-3.4.0-SNAPSHOT, not hibernate entity manager, hsqldb 1.8.0
Reporter: Ben Clark
Priority: Minor
Attachments: envers-patch.txt
I've been trying to use envers to add auditing functionality to an existing application and found a few minor bugs in the way which it persisted subclasses, and their properties. All were mapped with table-per-class-hierarchy. Also, there were some issues relating to hibernate proxies, where getClass() was returning the name of the enhanced class, not the actual class, or where session.guessEntityName() returned the name of the (proxied) superclass, not the actual class.
I also ran into a NPE when persisting a subclass where the changes were in collections belonging to the superclass, and another problem with access to private constructors which I think is already flagged as an issue.
I've attached a patch which resolves these issues, but it results in failures in the following tests: testHistoryOfId, testRevisionsCounts
Thanks,
Ben
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months
[Hibernate-JIRA] Created: (HHH-3736) Envers EntityInstantiator does not support private constructors for immutable entities
by Erik-Berndt Scheper (JIRA)
Envers EntityInstantiator does not support private constructors for immutable entities
--------------------------------------------------------------------------------------
Key: HHH-3736
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3736
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.4
Reporter: Erik-Berndt Scheper
Hibernate supports the use of private constructors in JPA, which is typically used for immutable entities.
Auditing of these entities works perfectly fine. However, retrieving audit records using getAuditReader().find leads to an IllegalAccessException in org.hibernate.envers.entities.EntityInstantiator
See attached test case to reproduce this.
Stack trace:
org.hibernate.envers.exception.AuditException: java.lang.IllegalAccessException: Class org.hibernate.envers.entities.EntityInstantiator can not access a member of class org.hibernate.envers.ebstest.entities.Country with modifiers "private"
at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:85)
at org.hibernate.envers.entities.EntityInstantiator.addInstancesFromVersionsEntities(EntityInstantiator.java:102)
at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:90)
at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:104)
at org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:103)
at org.hibernate.envers.ebstest.integration.accesstype.ImmutableFieldAccessType.testHistoryOfId1(ImmutableFieldAccessType.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:712)
at org.testng.TestRunner.privateRun(TestRunner.java:582)
at org.testng.TestRunner.run(TestRunner.java:477)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:198)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
at org.testng.TestNG.run(TestNG.java:708)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
Caused by: java.lang.IllegalAccessException: Class org.hibernate.envers.entities.EntityInstantiator can not access a member of class org.hibernate.envers.ebstest.entities.Country with modifiers "private"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
at java.lang.Class.newInstance0(Class.java:344)
at java.lang.Class.newInstance(Class.java:303)
at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:83)
... 27 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 11 months