0

I have a question regarding using JQL from javers If I have three model x,y and z with relationship :

model x:

@GeneratedValue(strategy = GenerationType.IDENTITY)
   @Column(name = "x_ID")
   private Long xId;

   @Column(name = "A")
   private string  a;

   @JsonIgnore
   @OneToMany(mappedBy = "x")
   private List<y> yList;

Model z:

@GeneratedValue(strategy = GenerationType.IDENTITY)
   @Column(name = "z_ID")
   private Long zId;

   @JsonIgnore
   @OneToMany(mappedBy = "z")
   private List<y> yList;

Model y:

 @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   @Column(name = "y_ID")
    private Long yId;

    @ManyToOne(fetch = FetchType.LAZY)
    @PrimaryKeyJoinColumn(name = "x_ID")
    private x x1;

    @Column(name = "x_ID")
    private Long xId;

    @ManyToOne(fetch = FetchType.LAZY)
    @PrimaryKeyJoinColumn(name = "z_ID")
    private z z1;

    @Column(name = "z_ID")
    private Long zId;

and here is a sample of what saved in snapshot table:

for x state:

{ "A": "test", "y": [],"xId": 1}

for z state:

{ "y": [],"zId":1}

for y state:

{ "yId": 1, ,"xId": 1, "zId":1}

My question is how to get the changes from the three states search by test ?.

janisz
  • 6,292
  • 4
  • 37
  • 70
yehia
  • 17
  • 5

1 Answers1

0

In general, in JQL there are no SQL-like joins for Entities.

So if you have 2 Entities (X and Y), joined with OneToMany relationship, you cant query like this: 'give me all snapshots of Y which are joined to my Entity X with id 1'.

But you can achieve this when you slightly change your model. If Y would be ValueObject (object without identity) owned by Entity X, than you can query in JQL: 'give me all snapshots (or changes) done on ValueObject Y owned by my Entity X with id 1'.

Bartek Walacik
  • 3,386
  • 1
  • 9
  • 14