사용자 도구

사이트 도구


java:hibernate:hql

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

java:hibernate:hql [2018/09/17 17:22]
kwon37xi 만듦
java:hibernate:hql [2018/09/17 17:23] (현재)
kwon37xi
줄 3: 줄 3:
 ===== HQL 결과를 사용자 정의 객체로 전환 ===== ===== HQL 결과를 사용자 정의 객체로 전환 =====
   * [[https://www.baeldung.com/hibernate-query-to-custom-class|Mapping A Hibernate Query To A Custom Class | Baeldung]]   * [[https://www.baeldung.com/hibernate-query-to-custom-class|Mapping A Hibernate Query To A Custom Class | Baeldung]]
- +  * HQL Constructor <code java> 
 +Query<Result> query = session.createQuery("select new com.baeldung.hibernate.pojo.Result(m.name, m.department.name)" 
 +  + " from com.baeldung.hibernate.entities.DeptEmployee m"); 
 +List<Result> results = query.list(); 
 +</code> 
 +  * ResultTransformer <code java> 
 +Query query = session.createQuery("select m.name as employeeName, m.department.name as departmentName" 
 +  + " from com.baeldung.hibernate.entities.DeptEmployee m"); 
 +query.setResultTransformer(Transformers.aliasToBean(Result.class)); 
 +List<Result> results = query.list(); 
 +</code>
   * [[java:querydsl|QueryDSL]] 사용시에는 Projection 을 사용하면 된다.   * [[java:querydsl|QueryDSL]] 사용시에는 Projection 을 사용하면 된다.
  
java/hibernate/hql.txt · 마지막으로 수정됨: 2018/09/17 17:23 저자 kwon37xi