Skip to content

[✨FEATURE] findById(Integer)' in 'com.example.narshaback.repository.NoticeRepository' clashes with 'findById(ID)' in 'org.springframework.data.repository.CrudRepository'; attempting to use incompatible return type #2

@otcroz

Description

@otcroz

기능 요청이 문제와 관련이 있습니까? 설명해주세요.

findById(Integer)' in 'com.example.narshaback.repository.NoticeRepository' clashes with 'findById(ID)' in 'org.springframework.data.repository.CrudRepository'; attempting to use incompatible return type

원하는 솔루션 설명
repository에서 Optional<getNotice> findById(Integer NoticeId);
리턴 타입을 작성하고 싶었으나 위 오류가 발생함. Optional<NoticeEntity> findById(Integer NoticeId);으로 작성함.
후자의 단점은 사용하지 않는 정보까지 반환해야 한다는 문제가 있음.

고려한 대안을 설명하세요
리턴 타입을 Optional으로 하고 싶음.

참고자료
https://creampuffy.tistory.com/162
https://sowon-dev.github.io/2022/07/10/220711JPA-optional/

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions