I have two tables, a table userand a table user_avatar. For each user in the table user_avatarthere are 3 entries, for 3 sizes of avatars (large, medium, small).
There user_avataris a column in the table userIdthat refers to the field User.idto indicate which user the avatar belongs to.
Here is my class UserAvatar:
@Entity @Table(name = "user_avatar")
public class UserAvatar
{
@Id @GeneratedValue
private long id;
@ManyToOne
@JoinColumn(name = "userId")
private User user;
@Enumerated(EnumType.STRING)
private AvatarSize size;
private String file;
private String s3Key;
@Override
public String toString()
{
return size + " " + file;
}
}
And this is how I access it in `user
@Entity
public class User
{
@Id @GeneratedValue
public Long id;
@OneToMany
@JoinColumn(name = "id")
@OrderColumn(name = "id")
public UserAvatar[] avatar;
}
When I run this code, I get an error message:
Repeated column in mapping for collection: com.xxx.User.avatar column: id
What am I doing wrong?
source
share