| For example.
public class TestEntity {
@Id
private int id;
@ElementCollection
private Map<String, Emb> embs1;
}
@Embeddable
public class Emb {
private String value;
public Emb(value) {
this.value = value;
}
}
TestEntity e = new TestEntity();
e.id = 1;
e.embs1 = new HashMap<>();
e.embs1.put("a", new Emb("value1"));
e.embs1.put("b", new Emb("value2"));
em.persist(e);
In TestEntity table:
In TestEntity_embs1
| TestEntity_id |
emb1_KEY |
value |
| 1 |
a |
value1 |
| 1 |
b |
value2 |
In TestEntity_embs1_AUD
| REV |
REVTYPE |
TestEntity_id |
emb1_KEY |
value |
REVEND |
REVEND_TSTMP |
| 1 |
0 |
1 |
a |
value1 |
NULL |
NULL |
| 1 |
0 |
1 |
b |
value2 |
NULL |
NULL |
All is ok. but if i edit the entity like this:
TestEntity e = em.find(TestEntity.class, 1);
e.put("a", "value3")
In TestEntity_embs1_AUD
| REV |
REVTYPE |
TestEntity_id |
emb1_KEY |
value |
REVEND |
REVEND_TSTMP |
| 1 |
0 |
1 |
a |
value1 |
2 |
2018-05-21 15:18:26.8850000 |
| 1 |
0 |
1 |
b |
value2 |
2 |
2018-05-21 15:18:26.8850000 |
| 2 |
0 |
1 |
a |
value3 |
NULL |
NULL |
| 2 |
0 |
1 |
b |
value2 |
2 |
2018-05-21 15:18:26.8850000 |
| 2 |
2 |
1 |
a |
value1 |
NULL |
NULL |
| 2 |
2 |
1 |
b |
value2 |
NULL |
NULL |
If I want to find the audit data of TestEntity with id 1, it return that:
[
{
id: 1
embs1: {
a: "value3"
}
},
{
id: 1
embs1: {
a: "value1",
b: "value2"
}
}
]
{b: "value2} is missing in the latest reversion. If I change the data in datebase by sql to these:
| REV |
REVTYPE |
TestEntity_id |
emb1_KEY |
value |
REVEND |
REVEND_TSTMP |
| 1 |
0 |
1 |
a |
value1 |
2 |
2018-05-21 15:18:26.8850000 |
| 1 |
0 |
1 |
b |
value2 |
2 |
2018-05-21 15:18:26.8850000 |
| 2 |
0 |
1 |
a |
value3 |
NULL |
NULL |
| 2 |
0 |
1 |
b |
value2 |
NULL |
NULL |
| 2 |
2 |
1 |
a |
value1 |
2 |
2018-05-21 15:18:26.8850000 |
| 2 |
2 |
1 |
b |
value2 |
2 |
2018-05-21 15:18:26.8850000 |
All is ok. I think it is a serious bug. it destory the function of audit of ElementCollection. |