0

I am logging changes made in an object graph and am receiving a ReferenceChange (which is correct):

ReferenceChange{globalId:'JaversTest2$BeanWithField/1', property:'integerHolder', oldRef:'JaversTest2$IntegerHolder/4', newRef:'JaversTest2$IntegerHolder/3'}

Is there any way for me to retrieve the actual reference object with the globalId: "JaversTest2$IntegerHolder/4" as I would like to log the actual before and after values?

stacktrace
  • 547
  • 1
  • 6
  • 19

1 Answers1

1

Short answer is no. If you are using javers.compare(), those objects are available only in ObjectGraph, which is internal JaVers data structure.

Think about changing your mapping. In this case, if you need values from changed objects try to map them as ValueObjects (not Entities).

Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14
  • Thanks for the quick answer. I had started down that path before you answered and it might work in this case - unfortunately it means configuring my javers instance differently (i.e Entity / Values) depending on what domain objects I'm comparing. Would it be a reasonable change to expose these references in the ReferenceChange object - similar to what's available for other change types? – stacktrace Jan 06 '16 at 23:28
  • Yes, it would be reasonable to add these refs to ReferenceChange, but object references would be available only for fresh diffs (created by `javers.compare()`) and not for diffs created by JQL – Bartek Walacik Jan 07 '16 at 19:54
  • That would work for my use case. Should I file a change request? – stacktrace Jan 07 '16 at 20:44
  • Thanks for your help. [Issue 286](https://github.com/javers/javers/issues/286) has been created. – stacktrace Jan 07 '16 at 21:12