JPQL (Java Persistence Query Language) 객체지향 쿼리 언어이기 때문에 테이블을 대상으로 쿼리 하는 것이 아니라 엔티티 객체를 대상으로 쿼리 한다. JPQL은 SQL을 추상화해서 특정 데이터베이스 SQL에 의존하지 않는다. JPQL은 결국 SQL로 변환된다. select_문 :: = select m from Member as m [where_절] [groupby_절] [having_절] [orderby_절] update_문 :: = update m [where_절] delete_문 :: = delete m [where_절] 엔티티와 속성은 대소문자를 구문하고 JPQL 키워드는 대소문자를 구분하지 않는다. 테이블의 이름이 아닌 엔티티의 이름을 사용하고 별칭(m)은 필수로 사용한..
JPA는 다양한 쿼리 방법을 지원한다. JPQL (대부분 이 방식을 사용) JPA Criteria QueryDSL 네이티브 SQL JDBC API 직접사용, MyBatis, SpringJdbcTemplate 함께 사용 JPQL 가장 단순한 조회 방법 EntityManager.find() 객체 그래프 탐색 a.get() 기타 등등 ... 하지만 특별한 조건을 포함한 데이터를 알고 싶다면? EntityManagerFactory emf = Persistence.createEntityManagerFactory("Test"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); tx.begin(); try..