如何获得可嵌入的变化?
How to get changes of embeddable?
我在 spring 引导中有一个带有嵌入式实体的实体。
现在,当我的嵌入式实体发生更改并且我查询我的实体更改时,更改不在更改列表中。
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Embedded
private LockSettingsEmbeddable lockSettings;
}
@Embeddable
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LockSettingsEmbeddable {
private boolean locked;
@Enumerated(EnumType.STRING)
private TaskLock lockSetting;
}
List<Change> changes = javers.findChanges(QueryBuilder.byInstanceId(taskId, TaskEntity.class).build());
List<Change> modifiableList = new ArrayList<>(changes);
modifiableList.sort((o1, o2) -> -1 * o1.getCommitMetadata().get().getCommitDate().compareTo(o2.getCommitMetadata().get().getCommitDate()));
return javers.getJsonConverter().toJson(modifiableList);
只需启用 withChildValueObject
过滤器,请参阅
https://javers.org/documentation/jql-examples/#child-value-objects-filter
我在 spring 引导中有一个带有嵌入式实体的实体。
现在,当我的嵌入式实体发生更改并且我查询我的实体更改时,更改不在更改列表中。
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Embedded
private LockSettingsEmbeddable lockSettings;
}
@Embeddable
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LockSettingsEmbeddable {
private boolean locked;
@Enumerated(EnumType.STRING)
private TaskLock lockSetting;
}
List<Change> changes = javers.findChanges(QueryBuilder.byInstanceId(taskId, TaskEntity.class).build());
List<Change> modifiableList = new ArrayList<>(changes);
modifiableList.sort((o1, o2) -> -1 * o1.getCommitMetadata().get().getCommitDate().compareTo(o2.getCommitMetadata().get().getCommitDate()));
return javers.getJsonConverter().toJson(modifiableList);
只需启用 withChildValueObject
过滤器,请参阅
https://javers.org/documentation/jql-examples/#child-value-objects-filter