Hibernate Envers Audit Unverified Objects

I have several classes in my project that are processed by Hibernate, some are checked by Envers, some are not. Now, when I try to save a specific unaudited object, I get the following:

java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: audit_etc_etc)

Some might think that I simply do not have an audit table in my database, but Envers should not even try to look for this table, because the entity is not checked. My classes look like this:

@Entity
class A {
    /* some 'normal' attributes here */

    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    AuditedEntity e;

    List<B> listOfBs;
}

@Entity
class B {
    /* more 'normal' attributes here */

    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    AuditedEntity e; // and some more references to audited entities

    A anA;

    List<C> listOfCs;
}

@Entity
class C {
    /* more 'normal' attributes here */

    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    AuditedEntity e; // and some more references to audited entities

    B anB;
}

Thus, each class contains a list of children who have a link to their parent. None of these classes are marked with @Audited-nnotation, but they do have references to some validated objects. However, each of these links is marked with @Audited(targetAuditMode = RelationTargetAuditMode. NOT_AUDITED)-nnotation.

hibernate.cfg.xml , , -, .

?

(: A B, , C )

Update:
show_sql , B:

Hibernate: update table_b set all_attributes=? where idB=?
Hibernate: insert into audit_description (timestamp, description) values (?, ?)
Hibernate: insert into audit_table_b (revision_type, attributes, moreAttributes, revision) values (?, ?, ?, ?)
+4
3

, yout @Audited, , , . @Audited , :

@Audited
@Entity
public class AuditedEntity{
  ...
}

@Entity
class A {
    AuditedEntity e;
    ...
}

AuditedEntity :

@Entity
@Audited
public class AnotherAuditedEntity {
    @Audited
    AuditedEntity e;
    ...
}
+2

@Audited . , A, B C, E A, B C.

:

@Entity
@Audited
public class E {
  @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
  private A a;
  @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
  private B b;
  @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)     
  private C c;
}

, .

+2

, @Audited(...) Envers . @NotAudited @Audited(..) , , .

0
source

Source: https://habr.com/ru/post/1607800/


All Articles