select
m
public interface MemberRepository extends JpaRepository<Member, Long>{
@Query("select m from Member m where m.username = :username and m.age = :age")
List<Member> findUser(@Param("username") String username, @Param("age") int age);
}
select
m.username
JPA 값 타입(@Embedded)
도 이 방식으로 조회
public interface MemberRepository extends JpaRepository<Member, Long>{
@Query("select m.username from Member m")
List<String> findUsernameList();
}
select
new [패키지명경로.DTO명]()
🚨주의🚨
패키지 경로 모두 작성!!
public interface MemberRepository extends JpaRepository<Member, Long>{
@Query("select new study.datajpa.dto.MemberDto(m.id, m.username, t.name) from Member m join m.team t")
List<MemberDto> findMemberDto();
}