-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Envers Properties.
PostPosted: Tue Jul 14, 2015 4:52 pm 
Newbie

Joined: Tue Jul 14, 2015 4:44 pm
Posts: 1
I'm new to using Hibernate Envers Properties.

Does anyone know how I can save a new record where the if the properties values are the same, I would want Envers not to report the property as having been changed?

For example:

public class Pie
@Entity
@Audited
{
//ommitting the setters and getters
@GeneratedValue (strategy = GenerationType.AUTO)
@Column(name = "id")

@Audited
@Column(name="fruit")
String fruit = apple;

@Audited(withModifiedFlag=true)
@Column(name="diameter")
String diameter = "12 inch pie"
}

I create first apple pie that has 12 inch diameter. I later add another pie, a cherry pie, and the diameter is also 12 inches. Note that I've set audited(withModifiedFlag=true) only on the diameter of the pie.

I would like to see in the audit table:

Rev | fruit | diameter | diameter_mod
---------------------------------------------------
xx | cherry | 12 inch pie | 0
---------------------------------------------------
xx | apple | 12 inch pie | 1

Is this even possible?

What I've tried was that if I create a new object and then use save or saveOrUpdate, I would see that diameter_mod equals to 1 for cherry pie. Is there anyway I can create the cherry pie with the same 12 inch and have Envers report
diameter_mod is 0 like above?

If I were to retrieve the apple pie through a session and modify the apple pie into a cherry pie, then diameter_mod would return 0.

Pie p = (Pie) session.get(Pie.class, 1)...
p.setDiameter(12);
PieFactory.saveOrUpdate(pie, session);

Instead of modifying an existing record, I would like to create a brand new Pie object and persist it in the database, for example, new Pie ("pumpkin", "12 inch pie") and I would like to see the audit table to say that the size has not changed by showing a 0 for the pumpkin pie's diameter. Is this possible with Envers?

Thanks in advance.


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

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.