Christophe Silon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6401c2b...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDU5ODgzMGUy...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16251?atlOrigin=eyJpIjoiZDU5OD...
) HHH-16251 (
https://hibernate.atlassian.net/browse/HHH-16251?atlOrigin=eyJpIjoiZDU5OD...
) Hibernate Envers wrong modified flag on OneToMany relations (
https://hibernate.atlassian.net/browse/HHH-16251?atlOrigin=eyJpIjoiZDU5OD...
)
Issue Type: Bug Affects Versions: 5.3.28, 6.2.0.CR3 Assignee: Chris Cranford (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-envers Created: 03/Mar/2023 06:44 AM Environment: Java 17
database platform: postgreSql, h2
Priority: Major Reporter: Christophe Silon (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6401c2b...
)
The values of the “_MOD” fields are incorrect in specific cases.
@Entity
@Table(name = "PERSON")
@Audited(withModifiedFlag = true)
public class PersonEntity {
@Id
@Column(name = "ID_PERSONNE")
private Long id;
@Column(name = "NAME", length = 100)
private String name;
@Audited( withModifiedFlag = true, modifiedColumnName = "SERVICES_MOD")
private Set<PersonneServiceEntity> services = new HashSet<>(); // Entity
with attributs, gettters, setters and envers annotations...
@Audited( withModifiedFlag = true, modifiedColumnName = "OPT_INS_MOD")
private Set<OptinEntity> optIns = new HashSet<>();// Entity with attributs,
gettters, setters and envers annotations...
// more fields
// + getters, setteurs, equals, tostring
The problem happens when you try in the same transaction, to modify in this example, the “
PersonEntity " entity (by modifying the name), and add an entity to multiple
OneToMany relations (in the above example, if you add an entity into services and an
entity into optIns ), the flag of the modified fields in the entity will be correct, but
only the flag of the first collection modified will be set.
For example:
* Modify the name
* Add a PersonneServiceEntity to the services relation
* Add a OptinEntity to the optIns relation
When you check the values in the database, you will see that all the flag will be
correctly set except the OPT_INS_MOD flag.
If you add a OptinEntity before the PersonneServiceEntity , then the OPT_INS_MOD flag will
be set correctly but not the SERVICES_MOD flag.
If you don’t modify the name, then the flag of all collections will be set correctly.
(This is the same problem as
https://stackoverflow.com/questions/64011351/hibernate-envers-wrong-modif...
(
https://stackoverflow.com/questions/64011351/hibernate-envers-wrong-modif...
) )
(
https://hibernate.atlassian.net/browse/HHH-16251#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16251#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#100217- sha1:65be9f2 )