【发布时间】:2017-08-17 03:03:40
【问题描述】:
我目前使用的是 Hibernate & Envers 版本 5.2.9.Final。我想将 @ElementCollection 与 custom table name 一起用于 collection 和 audit table。
目前我所知道的是,修改默认表名有多种注释可以使用:对于实体本身,有注释@Table 和@SecondaryTable 以及相应的envers 注释@AuditTable 和@SecondaryAuditTable。要更改元素集合的表名,可以使用 @CollectionTable 注释。到目前为止,我还没有找到相应的 envers 注释。所以我的问题是:
如何更改休眠 @ElementCollection envers 审计表的名称?
其他信息
在元素集合的hibernate envers ticket which tracks the adding of auditing support 中,同样的问题早在 2013 年就被问到但没有得到回答。
code sn-p 让我的设置更清晰:
@Entity
@Table(name = "\"user\"")
@SecondaryTable(name = "\"user_secondary\"")
@Audited
@AuditTable("\"user_audit\"")
@SecondaryAuditTable(secondaryTableName = "user_secondary",
secondaryAuditTableName = "\"user_secondary_audit\"")
public class User {
// ... stuff like id and other fields ...
@ElementCollection
@CollectionTable(name = "\"user_references\"")
private Map<String, Long> references = new HashMap<>();
// TODO FIXME how to get a custom name for the audit table?
// ... more stuff like getters and setters
}
Hibernate 按预期生成所有表,但 collecction 审计表名为 'user_references_AUD' 而我想 获得名称 'user_references_audit' 喜欢其他表。
我也知道影响审计表前缀或后缀的全局设置,但这只是我用例的最后手段。
更新
按照建议,我向 Hibernate JIRA 添加了 feature request。
【问题讨论】:
标签: java hibernate-envers