java - How not to audit a join table and related entities using Hibernate Envers? -


I use Eners to be hibernate to audit my institutions.

I have an audit entity, Foo , which includes a list & lt; Bars & gt; However, I do not want to audit the bar institutions, in the form of properties, I have written that:

  @inti @edicated public class Foo {@JoinTable (name = "T_FOO_BAR", joinColumns = @JoinColumn (name = "FOO_ID"), inverseJoinColumns = @JoinColumn (Name = "BAR_ID")) @ManyToMany (Cascade = Persist) @ Indited (targetAuditMode = RelationTargetAuditMode.NOT_AUDITED ) Public listing & lt; Bars & gt; GetBars () {Return bars; }}  

Now, I want to retrieve an amendment of foo :

  AuditReader reader = AuditReaderFactory.get (GetEntityManager ()); FU modification = (FU) reader.CreativeTeA () .entensEtrevision (Foo Class, 42) .getSingleResult (); Unfortunately, when I want to retrieve all the data (i.e. when it loads lazy  times ), error me  ORA-00942: table or view is not present , because Tried to query this: 

  Select ... to T_FOO_BAR_AUD x, T_BAR y where ...  

Although @audio ( TargetAuditMode = RelationTargetAuditMode.NOT_AUDITED), , the Hibernate Environment will keep links with the current unit's bar objects.

So how can I solve my problem without the audit of the tables T_BAR and T_FOO_BAR (table included)? In other words, when I retrieve the list of bar from my revision unit, I get a list of bar from my current entity (as Foo and times are not audited).

Thank you.

It looks like you have @Audited (targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) in your code < / Code>, you should use @NotAudited in your code.

RelationshipsTightedMode.NOT_AUDITED will only audit Target unit list & lt; Bars & gt; Try to audit the property of Foo , and thus include the table.

From the docs:

If you want to audit a relationship, where the target unit has not been audited (for example, Such is the case with institutions, which do not change and do not audit), just annotate it with @ededit (targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) . Then, when reading the historical version of your organization, the relationship will always point to the "current" related entity.


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

mongodb - CakePHP paginator ignoring order, but only for certain values -