我在客户的项目中使用Javers 5.5.2,问题出在下一个: 我有2个实体:交通工具和情感。感情是车辆的孩子。
当我保存并提交车辆实体时,我希望Javers为我提供有关affecation的信息,但只返回受影响的ID。
/**
* A Vehicule.
*/
@Entity
@Table(name = "vehicule")
@Document(indexName = "vehicule")
public class Vehicule implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator
"sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Pattern(regexp = "^[A-Z]$")
@Column(name = "categorie_assurance")
private String categorieAssurance;
@ManyToOne
@JsonIgnoreProperties("vehicules")
private Affectation affectation;
**
* A Affectation.
*/
@Entity
@Table(name = "affectation")
@Document(indexName = "affectation")
public class Affectation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Column(name = "code", nullable = false)
private String code;
@Column(name = "commune", nullable = false)
private String commune;
@Column(name = "libelle", nullable = false)
private String libelle;
这是我从三叶草中进行审核的端点,我正在使用查找更改。
@RequestMapping("/vehicule/{id}/commits")
public ResponseEntity<List<ChangesByCommitAndChanges>> getVehiculeChangesByCommit(@PathVariable Integer id,
@RequestParam Optional<String> param) {
QueryBuilder jqlQuery = QueryBuilder
.byInstanceId(id, Vehicule.class)
.withNewObjectChanges(false)
.withChildValueObjects()
.limit(10);
jqlQuery = param.isPresent() ? jqlQuery.withChangedProperty(param.get()) : jqlQuery;
return ResponseEntity.ok().body(groupChangesByCommit(javers.findChanges(jqlQuery.build())));
}
此端点返回以下审核:
Commit 17.0 done by LAURIE Adèle at 04 juin 2019, 09:17:01 :
* changes on nc.opt.refauto.domain.Vehicule/11700 :
- 'affectation' reference changed from '...Affectation/7600' to '...Affectation/7900'
Commit 16.0 done by LAURIE Adèle at 04 juin 2019, 09:16:55 :
* changes on nc.opt.refauto.domain.Vehicule/11700 :
- 'pret' reference changed from '' to '...Affectation/7700'
Commit 2.0 done by LAURIE Adèle at 03 juin 2019, 16:23:01 :
* changes on nc.opt.refauto.domain.Vehicule/11700 :
- 'numeroCommande' value changed from '11-723' to '11-723aef'
- 'numeroMarche' value changed from '250/10' to '250/10efae'
- 'observations' value changed from 'efef' to 'efefefaef'
您可以在这些日志中看到,情感仅返回其ID,而不返回其他属性值(代码,公社,libelle)。