-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 5:13 am 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
Hi everyone.
I'm using Hibernate 5.1.0.Final and Envers 5.1.0.Final to persist a complex datamodel with revisions. I'm trying to tracking entity changes at property level.
My datamodel has few @Embedded entities as a fields in main class. Each of embeddable classes annotated as @Embeddable. All data for main entity and for embedded entities saved in one table in database.
My main entity annotated as @Audited(withModifiedFlag = true).
In _AUD table all fields are audited correctly, but Envers populates _MOD flags only for main entity and not for @Embedded entities.
I will be grateful for any suggestions to resolve this issue.


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 9:17 am 
Hibernate Team
Hibernate Team

Joined: Wed Jun 15, 2016 9:04 am
Posts: 24
kolekyr -

I just tested a very simplistic example using branch 5.1 and I was not able to reproduce the problem. Could you post your entity and any pertinent Envers configuration you're using?


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 11:21 am 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
@Naros

Here is some sample code
Main entity
Code:
@Entity
@Audited(withModifiedFlag = true)
@Table(name = "main_entiity")
@SequenceGenerator(name = "gen_main_entity_id", sequenceName = "seq_main_entity_id", allocationSize = 1, initalValue = 1)
public class MainEntity implements Serializable{
@Id
@GeneratedValue(generator = "gen_main_entity_id", strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "owner_name")
private String ownerName;
@Column(name = "owner_address")
private String ownerAddress;

/*some other fields*/

@Embedded
private EmbeddedEntity embeddedEntity;

/*Getters, Setters, */

}


Embedded entity
Code:
@Embeddable
public class EmbeddedEntity implements Serializable {
@Column(name = "embedded_name")
private String embeddedString;

/*some other fields*/

/*Getters, Setters, */
}


And if i tried to change only embeddedString field in embeddedString_MOD column in DB i have 0.
If i tried to chsnge any field, which is in MainEntity class - i have correct values in _MOD columns in DB.


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 11:34 am 
Hibernate Team
Hibernate Team

Joined: Wed Jun 15, 2016 9:04 am
Posts: 24
@kolekyr, what configuration settings, if any, do you have that start with "org.hibernate.envers"?


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 12:07 pm 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
AUDIT_STRATEGY_VALIDITY_STORE_REVEND_TIMESTAMP = true
hibernate.listeners.envers.autoRegister = false

And we have custom validity audit strategy, but inside it we don't handle any annotations - just added some specific columns besides standarts such as revision type, revision number etc

P.S. if i switch our custom strategy to default - i have the same result(just in minutes tested)


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 12:37 pm 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
@Naros
Could you please share with me your very simplistic example?


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 1:14 pm 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
@Naros
For quick testing i used sample project from the first google search page https://github.com/ignacioSuay/hibernate-envers-sample - it gives me the same results as my project.
I added @Embedded entity to existed entity and tried to change it. It creates _MOD column only for embedded entity as a field in main entity.


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Wed Jun 15, 2016 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Wed Jun 15, 2016 9:04 am
Posts: 24
My simple project can be seen at https://github.com/Naros/hibernate-orm/ ... d24a430972.

I originally misunderstood your post, so my apologies. You are correct in that Envers will create the MOD field only for the Embeddable property name in the containing entity. So for my test case, there would have only been a MOD field added for contactInfo and name, not for the properties that are within ContactInfo itself. This was by design.

I do see the use of being able to query changes of an Embeddable and other relations. The unfortunate part is that the modified flags logic is still considered incubating/experimental, and so we'll likely stumble across things like this until the behavior is flushed out completely. I have added https://hibernate.atlassian.net/browse/HHH-10859 to represent this new feature.


Top
 Profile  
 
 Post subject: Re: Envers not populates _MOD flags in embedded entities.
PostPosted: Fri Jun 17, 2016 5:35 am 
Newbie

Joined: Wed Jun 15, 2016 4:44 am
Posts: 6
Location: Ukraine
@Naros
Thanks for your attention


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.