Javers 将实体与 DTO 进行比较
Javers compare entity to DTO
我是 Javers 的新手,目前我正在使用它为我的实体创建补丁更新。但我在一个特定场景中遇到了一些困难
我想将实体与 EntityDTO/VO 进行比较,并且仅获取值的变化,当前比较仅 returns 即 NewObject 和 ObjectRemoved 发生变化。
示例:
public class Entity{
private ObjectId id;
private String name;
private String description;
}
public class EntityDTO{
private String name;
}
//
Entity oldState = new Entity(new ObjectId(), "oldName" , "oldDescription);
EntityDTO newState = new EntityDTO( "newName" );
JaversBuilder.javers().build().compare(oldState, newState).getChanges();
//This is returning only NewObject/ObjectRemoved changes, and the intended is to be ValueChange/ReferenceChange
问题是,有没有办法只比较对象之间相似的属性?
不可以,在 JaVers 中,您只能比较相同类型的对象。
我是 Javers 的新手,目前我正在使用它为我的实体创建补丁更新。但我在一个特定场景中遇到了一些困难
我想将实体与 EntityDTO/VO 进行比较,并且仅获取值的变化,当前比较仅 returns 即 NewObject 和 ObjectRemoved 发生变化。
示例:
public class Entity{
private ObjectId id;
private String name;
private String description;
}
public class EntityDTO{
private String name;
}
//
Entity oldState = new Entity(new ObjectId(), "oldName" , "oldDescription);
EntityDTO newState = new EntityDTO( "newName" );
JaversBuilder.javers().build().compare(oldState, newState).getChanges();
//This is returning only NewObject/ObjectRemoved changes, and the intended is to be ValueChange/ReferenceChange
问题是,有没有办法只比较对象之间相似的属性?
不可以,在 JaVers 中,您只能比较相同类型的对象。