Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

In my Spring/JPA/Hibernate/Envers PostgreSQL application I'm trying to implement Spring Data Auditing

I have a following entity:

@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;

where I have added:

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

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

at the database level I want to write INTEGER ID for created_by_user_id and last_modified_by_user_id but during execution my application throws an error that created_by_user_id should be bytea type.

What am I doping wrong and how to configure Spring Data Auditing to use INTEGER for this purpose ?

share|improve this question
1  
If you're trying reference a User table by User_Id you should specify with a @ManyToOne mapping. I don't use spring so I'm not sure if there's something different going on here. – Nicholas Smith Jun 20 at 19:37
    
Thanks! you are right – alexanoid Jun 20 at 21:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.