简体   繁体   English

如何创建自定义字段以将用户凭据存储在REVINFO表中

[英]How do I create custom field to store user credentials in REVINFO table

We are using hibernate-envers and having *_AUD table that stores historical state of entities. 我们正在使用hibernate-envers,并具有用于存储实体历史状态的* _AUD表。 There is also a global REVINFO table which contains revision number, timestamp. 还有一个全局REVINFO表,其中包含修订号,时间戳。

I need to add user as field in REVINFO table. 我需要在REVINFO表中将用户添加为字段。 How to add "user" field in REVINFO table? 如何在REVINFO表中添加“用户”字段?

You can definitely create your custom RevisionInfo entity. 您绝对可以创建自定义的RevisionInfo实体。 The custom revisions entity must have an integer-valued unique property (preferably the primary id) annotated with {@link RevisionNumber} and a long-valued property annotated with {@link RevisionTimestamp}. 自定义修订版本实体必须具有用{@link RevisionNumber}注释的整数值唯一属性(最好是主ID)和用{@link RevisionTimestamp}注释的长值属性。

The {@link DefaultRevisionEntity} already has those two fields, so you may extend it, but you may also write your own revision entity from scratch. {@link DefaultRevisionEntity}已经具有这两个字段,因此您可以对其进行扩展,但是也可以从头开始编写自己的修订实体。 So in your case the revision entity may look like following: 因此,在您的情况下,修订版实体可能如下所示:

@Entity
@RevisionEntity()
public class RevisionsInfo extends DefaultRevisionEntity {

  private Long userId;

  public Long getUserId() { return userId; }

  public void setUserId(final Long uid) { this.userId = uid; }

}

In addition to that you can also give your custom RevisionListener for any other special needs . 除此之外,您还可以为其他任何特殊需求提供自定义的RevisionListener。 See following example: 请参见以下示例:

public class RevisionListener implements org.hibernate.envers.RevisionListener
{
    /**
     * {@inheritDoc}
     */
    public void newRevision(final Object revisionInfo)
    {
        // updateInfo your info here if required
    }
}

The custom RevisionListener can be provided as an argument to RevisionEntity annotation. 可以将自定义RevisionListener作为RevisionEntity批注的参数提供。

@RevisionEntity(RevisionListener.class)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将自定义字段添加到 Hibernate Envers 修订表 (revinfo),如 operation_id。 哪个是Operation实体的PK - Add custom field to Hibernate Envers revision table (revinfo), like operation_id. Which is a PK of Operation entity 如何使用MD5转换密码并根据有效凭据检查用户凭据? - How do I use MD5 to convert passwords and check a user's credentials against valid credentials? 如何获取用户输入并将其存储到HashMap中并分别创建两个键以进行打印? - How do I get user input and store it into a HashMap and create the two keys separately to print out? 如何将用户详细信息存储为会话 - How do i store the user details as session 如何在Tapestry5中创建一个自定义文本字段,将一些Javascript呈现到页面上? - How do I create a custom text field in Tapestry5 that renders some Javascript onto the page? 我应该如何存储用户凭据,以便用户不必再次登录? - How should I store user credentials so that users don't have to login again? Hibernate RevInfo表Rev列已达到最大范围,即2147483647 - Hibernate RevInfo table Rev column is reached to maximum range i.e. 2147483647 如何创建标准,其中参数是表上集合字段的成员? - How do I create a criteria where the parameter is a member of a collection field on the table? 如何创建自定义日期? - how do i create a custom date? hibernate envers改变REVINFO表名 - hibernate envers alter REVINFO table name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM