Spring / JPA PostgreSQL - Spring数据审计INTEGER而不是bytea,Envers

时间:2016-06-20 19:34:35

标签: spring hibernate postgresql jpa spring-data

在我的Spring / JPA / Hibernate / Envers PostgreSQL应用程序中,我试图实现Spring Data Auditing

我有一个以下实体:

@Audited
@AuditTable("levels_history")
@Entity
@Table(name = "levels")
public class Level extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 642499791438799548L;

    @Id
    @SequenceGenerator(name = "levels_id_seq", sequenceName = "levels_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "levels_id_seq")
    private Long id;

    private String name;

    @NotAudited
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "level")
    private List<Card> card = new ArrayList<Card>();

    @CreatedBy
    @Column(name = "created_by_user_id")
    private User createdByUser;

    @LastModifiedBy
    @Column(name = "last_modified_by_user_id")
    private User lastModifiedByUser;

我添加了:

    @CreatedBy
    @Column(name = "created_by_user_id")
    private User createdByUser;

    @LastModifiedBy
    @Column(name = "last_modified_by_user_id")
    private User lastModifiedByUser;

在数据库级别我想为INTEGERcreated_by_user_id编写last_modified_by_user_id ID,但在执行期间,我的应用程序会抛出created_by_user_id应为bytea的错误类型。

我做错了什么以及如何配置Spring Data Auditing以便为此目的使用INTEGER

0 个答案:

没有答案