I can do it(Feat. DEV)

[Error]Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: 본문

개발자 모드/오류처리

[Error]Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements:

까짓거 해보자 개발자 2022. 10. 26. 10:29
728x90

게시판과 게시글 도메인을 만들던 중 에러를 만났음.

 

※에러 메세지 
- Illegal attempt to map a non collection as a @OneToMany,@ManyToMany or @CollectionOfElements: 도메인 경로

 

파파고 번역기를 돌려보니

비 컬렉션을 @OneToMany, @ManyToMany 또는 @CollectionOfElements로 매핑하려는 잘못된 시도:

라는 뜻이였음.

 

거두절미하고 갓글 검색하여 얻은 해결방법 !!

일대다인 @OneToMany를 설정한 Article을 List로 변경해야 한다는 것.

 

※해결방법

   //이전 코드
   @OneToMany
   private Article article;

 

 

    //변경된 코드
    @OneToMany
    private List<Article> articles;

 

필자가 일대다로 설정했는데 멍청 멍청하게 List 형태로 바꾸지 않았음...🤭

에러 해결!

 

📢참조

https://ppusari.tistory.com/183

 

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

오류메시지 Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements 해결방법 아마도 당신은 as-is 처럼 되어 있을 것입니다. to-be 처럼 List 나 Set 과..

ppusari.tistory.com

 

728x90