2

Is there a way to default ignore all fields except explicitly included in Javers? I'm trying to persist CGLib proxy objects, and it's picking up all of the CGLib fields along with the @Entity fields. So what I think would work better is ignore by default, and an annotation/config to say "use these fields".

I've also tried .withMappingStyle(MappingStyle.BEAN) which doesn't seem to make a difference.

Drizzt321
  • 993
  • 13
  • 27

1 Answers1

0

There is no such option but

  • you can ignore these CGLib proxy fields globally by type (if they have some meaningful types) using JaversBuilder.registerIgnoredClass(Class<?> ignoredClass)

  • I don't recommend committing CGLib proxy objects directly to JaVers. For Hibernate we have unproxy hook, see http://javers.org/documentation/domain-configuration/#hooks You can implememt unproxy hook for your ORM

Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14
  • I don't think they have one specific type, so not something easy to ignore like that. I'm actually kind of surprised that you do have a way to ignore specific fields, you don't have the inverse of only include specific fields. Somewhat makes sense, given that this is supposed to be an audit trail and you really want to include everything normally. And yes, saw the ObjectAccessHook, which I suppose I can use to unbox to the real Class type from the CGLib proxy object. – Drizzt321 Mar 30 '16 at 22:38
  • And I do see that apparently CGLib does create an additional getter method, thus even with Bean style mapping for getters it'd find the CGlib stuff. *sigh* – Drizzt321 Mar 30 '16 at 22:41