参考变更中的价值变化差异

时间:2016-03-05 14:06:03

标签: javers

我有一个Application实体和一个User实体。从应用程序到用户的一对多关系,即一个应用程序可以有多个用户 我更新用户并更改分配给他的应用程序。到目前为止,我有以下内容:

Diff diff = javers.compare(oldUser, newUser);
List<ReferenceChange> referenceChanges = diff.getChangesByType(ReferenceChange.class);
for (ReferenceChange referenceChange : referenceChanges) {
            Object oldRef = referenceChange.getLeftObject().get();
            Object newRef = referenceChange.getRightObject().get();             
            Diff refDiff = javers.compare(oldRef,newRef);               
        }

调试时请查看以下结果:
referenceChanges List:
ReferenceChange {globalId:&#39; com.ds.appmanager.services.domain.User / 3&#39;,property:&#39; application&#39;,oldRef:&#39; com.ds.appmanager.services。 domain.Application / 7&#39;,newRef:&#39; com.ds.appmanager.services.domain.Application / 3&#39;}
oldRef
应用程序[applicationId = 7,applicationName = KYC,applicationDesc = DEV_TEST,applicationLaunch = 2016-12-31 00:00:00.0,live = false]
newRef
申请[applicationId = 3,applicationName = KYC,applicationDesc = hellp,applicationLaunch = Sat Mar 12 00:00:00 IST 2016,live = true]

当我将两个对象传递给javers.compare(oldRef,newRef)时,它再次给出了与 referenceChanges 相同的结果。我认为它应该给我每个属性的值更改,例如,applicationDesc,oldVal = DEV_TEST,newVal = hellp。

我在这里遗漏了什么吗?我想要做的就是获取在User对象中引用的Application对象的属性的值更改。

P.S:如果我将Object oldRef = referenceChange.getLeftObject().get();更改为Object oldRef = referenceChange.getLeftObject();,我会JaversException: CLASS_EXTRACTION_ERROR JaVers bootstrap error - Don't know how to extract Class from type 'T'.

更新
刚才注意到我在执行Diff refDiff = javers.compare(oldRef,newRef);时没有获得ValueChanges 调试显示以下更改:

Diff:

1。 NewObject的{globalId:&#39; com.ds.appmanager.services.domain.Application / 7&#39;}
2. ObjectRemoved {globalId:&#39; com.ds.appmanager.services.domain.User / 5&#39;}
3. ObjectRemoved {globalId:&#39; com.ds.appmanager.services.domain.Application / 3&#39;}
4. ObjectRemoved {globalId:&#39; com.ds.appmanager.services.domain.User / 6&#39;}
5. ObjectRemoved {globalId:&#39; com.ds.appmanager.services.domain.User / 7&#39;}
6. ReferenceChange {globalId:&#39; com.ds.appmanager.services.domain.User / 3&#39;,property:&#39; application&#39;,oldRef:&#39; com.ds.appmanager。 services.domain.Application / 3&#39;,newRef:&#39; com.ds.appmanager.services.domain.Application / 7&#39;}

0 个答案:

没有答案