Pierre-Alexandre Mancaux (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ccadf3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjVmNTAyZTg4...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16154?atlOrigin=eyJpIjoiNjVmNT...
) HHH-16154 (
https://hibernate.atlassian.net/browse/HHH-16154?atlOrigin=eyJpIjoiNjVmNT...
) Hibernate envers and ElementCollection (
https://hibernate.atlassian.net/browse/HHH-16154?atlOrigin=eyJpIjoiNjVmNT...
)
Issue Type: Bug Affects Versions: 5.6.14 Assignee: Chris Cranford (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-envers Created: 09/Feb/2023 00:21 AM Priority: Major Reporter:
Pierre-Alexandre Mancaux (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ccadf3...
)
I have a simple program with a Resource and List of ItemSelection like this
@Audited
@Table(name = "resource_item")
public class Resource {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Access(AccessType.PROPERTY)
private Long id;
private String nom;
@ElementCollection(targetClass = ItemSelection.class)
@CollectionTable(name = "item_selection", joinColumns = @JoinColumn(name =
"resource_id"))
@OrderColumn(name = "list_order")
private final List<ItemSelection> itemSelections = new ArrayList<>();
...
...
@Embeddable
@Access(AccessType.FIELD)
public class ItemSelection {
//@Column(name = "hierarchy_code", nullable = false)
private String hierarchyCode;
//@Column(name = "hierarchy_level", nullable = false)
private int hierarchyLevel;
//@Column(name = "hierarchy_value_code", nullable = false)
private String hierarchyValueCode;
...
...
When i m adding resource with 3 elements in itemSelections, hibernate envers log
correctly:
localhost sa@envers=# select * from item_selection_aud ;
rev | revtype | resource_id | list_order | hierarchy_value_code | hierarchy_code |
hierarchy_level
-----+---------+-------------+------------+----------------------+----------------+-----------------
2 | 0 | 1 | 1 | hvalueCode3 | hcode3 |
3
2 | 0 | 1 | 0 | hvalueCode1 | hcode1 |
1
2 | 0 | 1 | 2 | hvalueCode2 | hcode2 |
2
(3 rows)
when i m updating one line in item_selection, i only see one update in sql but hibernate
envers log this:
localhost sa@envers=# select * from item_selection_aud ;
rev | revtype | resource_id | list_order | hierarchy_value_code | hierarchy_code |
hierarchy_level
-----+---------+-------------+------------+----------------------+----------------+-----------------
2 | 0 | 1 | 1 | hvalueCode3 | hcode3 |
3
2 | 0 | 1 | 0 | hvalueCode1 | hcode1 |
1
2 | 0 | 1 | 2 | hvalueCode2 | hcode2 |
2
3 | 0 | 1 | 0 | hvalueCode1 | CODE |
1
3 | 2 | 1 | 0 | hvalueCode1 | hcode1 |
1
(5 rows)
as you can see, i have a revtype 2 and 0 for the modified line instead of revtype 1 for an
update.
I'have try to use @Column(name = "hierarchy_code", nullable = false) but
nothing change.
For now my only solution is to transform @ElementCollection into @OneToMany, but I have
many @ElementCollection in my application so too many refactoring...
Did I miss something in the configuration? I am using DefaultAuditStrategy, same behavior
with ValidityAuditStrategy that only add revend column. Hibernate-envers 5.6.12-Final
(
https://hibernate.atlassian.net/browse/HHH-16154#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16154#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100215- sha1:a0f3b6a )