-
-
Notifications
You must be signed in to change notification settings - Fork 390
Description
Google have a nice library AutoValue to generate immutable object model classes. To use this you create a public abstract class with abstract methods for each object property and at compile time an implementation is generated with package class access.
There are several issues when trying to use this library:
-
The
Idattribute is not picked up without switching to MappingStyle.BEAN -
The
Idattribute is not picked up on an abstract method -
Due to the way properties are looked up using reflection this results in
IllegalAccessExceptions being throw fromorg.javers.common.reflection.JaversGetter. It would be possible to avoid this & potentially other polymorphic issues by traversing up the class hierarchy until you find a public class on which to perform reflection.
I have created a failing test here which fails with the InvocationTargetException.
If you move the @Id attribute from Animal#getJaversId to Animal#getName the tests fail with an ENTITY_WITHOUT_ID error.
If you remove .withMappingStyle(MappingStyle.BEAN).registerEntity(Animal.class) then the test will fail with id = 1.0 not Cat.
I would be happy to help fix this with some pointers.