我正在尝试使用Hibernate envers生成数据库中数据的修订版。我在实体上添加了@Audited。这些表是在数据库中生成的,但是当我更改数据时没有生成修订。
我正在使用Spring 1.5.6.RELEASE和Hibernate版本5.2.9。我使用CrudRepository更新数据库。这是我的实体:
@Entity
@Audited
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "table")
@Getter
@Setter
@NoArgsConstructor
public class Unit implements Serializable {
@Column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
public Type type;
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "suid")
private String suid;
@Column(name = "label")
private String label;
@Column(name = "extAddressID")
private String extAddressID;
}
这是我的配置:
platform: postgres
initialize: true
driver-class-name: org.postgresql.Driver
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
show-sql: true
format-sql: true
use_sql_comments: true
hibernate:
ddl-auto: update
properties:
hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate.type: trace
hibernate.show_sql: true
hibernate.format_sql: true
hibernate.use_sql_comments: false
org.hibernate.envers.audit_table_suffix: _vo
org.hibernate.envers.default_schema: versioned_object
org.hibernate.envers.audit_strategy: org.hibernate.envers.strategy.ValidityAuditStrategy
org.hibernate.envers.revision_field_name: begin_lifespan_version
org.hibernate.envers.audit_strategy_validity_end_rev_field_name: end_lifespan_version
org.hibernate.envers.audit_strategy_validity_store_revend_timestamp: true