-
1. Re: Object is not retrieved correctly
hernanbolido Jun 17, 2011 6:43 PM (in response to n.mirzadeh)Hi!
I think that having the relation from StateTransition to Event marked targetAuditMode= RelationTargetAuditMode.NOT_AUDITED and having the entity Event audited is a bit confusing...
Do you want to audit Event or not?
The semantic of the relationTargetAuditMode.NOT _AUDITED is that the related entity hasn`t history. There is not a hoctoric table and instead of that, envers resolve the relation to the entity through hibernate session.
I hope it will be helpful.
Regards. Hernán.
-
2. Re: Object is not retrieved correctly
n.mirzadeh Jun 19, 2011 3:52 PM (in response to hernanbolido)Hi Hernan,
I realised this behaviour yesterday. In my case the Event and StateTransition objects are manipulated in different transactions, hence, they get different revision numbers. If I remove the relationTargetAuditMode.NOT _AUDITED annotation from the Event, then Evenrs would resolve the association from the Event historic table with the same revision number as the (historic) audited-StateTransition object. In other words, in this case getting the Event object from the historic StateTransition would always return null as the result of removing relationTargetAuditMode.NOT _AUDITED. Another option is NOT to audit the Event. But, the later means that I would lose the logs on creation and changes made to the Event objects.
So, how can I get around this issue?
Regards,
Nader
-
3. Re: Object is not retrieved correctly
adamw Jun 20, 2011 1:57 PM (in response to n.mirzadeh)Again, I don't quite understand why you would get a null there . I think you would get null only if the Event/StateTransition didn't exist at a given revision. Otherwise, you should get correct data.
Maybe you can create a small test case on what you are trying to achieve, so that it will be easier for both of us to understand what's going on?
Adam
-
4. Re: Object is not retrieved correctly
n.mirzadeh Jun 21, 2011 7:03 AM (in response to adamw)Hi Adam,
looking at the code, Envers uses the annotation on an entity to determine whether to retrieve it from the historic-table or the table where the entity is stored. It be more correct to leave this decision to the annotation on the relation, then the expected data should correctly be retrieved.
-
5. Re: Object is not retrieved correctly
adamw Jun 27, 2011 11:08 AM (in response to n.mirzadeh)Hmm I don't get the difference in the approaches you described
Adam