Post

Spring AnnotationException - Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements

[에러 메시지] AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements


해결 방법

  • 에러나는 코드
1
2
3
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "userId")
private UserEntity userId;


  • UserEntityList로 고치기
1
2
3
@OneToMany(mappedBy = "music_like", fetch = FetchType.LAZY)
@JoinColumn(name = "userId")
private List<UserEntity> userId;
This post is licensed under CC BY 4.0 by the author.