I have 2 classes, an Abstract class annotated with @MappedSuperclass and a child class which extends the class. When i run my program, i get the following error:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: models.Comment column: comment_id (should be mapped with insert="false" update="false")
But I'm looking through my code and I don't see any repeated column names. This is my first time using the Mapped supper class annotation and I'm not sure if I am doing something wrong/using the annotation. Here are the two classes I have:
@MappedSuperclass
public abstract class AbstractModel {
protected long id;
protected Date creationDate = new Date();
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Temporal(TemporalType.TIMESTAMP)
public Date getCreationDate() {
return creationDate;
}
}
and
@Entity
@Table(name="comment")
@AttributeOverride(name = "id", column = @Column(name = "comment_id"))
public class Comment extends AbstractModel{
private User user;
private Post post;
private String content;
/*
* Getters and setters
*
*/
@Override
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public long getId(){
return id;
}
@ManyToOne
@JoinColumn(name="user_id")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@ManyToOne
@JoinColumn(name="post_id")
public Post getPost() {
return post;
}
public void setPost(Post post) {
this.post = post;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
Any help with this would be greatly appreciated