[JPA & Hibernate] Native Queries

원알렉스·2020년 8월 10일
0

JPA

목록 보기
5/16
post-thumbnail
post-custom-banner

깃허브 소스코드
Udemy 강의영상

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = JpaApplication.class)
public class NativeQueriesTests {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private EntityManager entityManager;

    @Test
    public void findAllWithNativeQuery() {
        Query query = entityManager.createNativeQuery("SELECT * FROM courses", Course.class);
        List<?> courses = query.getResultList();
        logger.info(String.format("SELECT * FROM courses -> %s", courses));
    }
}
profile
Alex's Develog 🤔
post-custom-banner

0개의 댓글