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.
|