문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
java:querydsl [2014/09/14 15:50] kwon37xi |
java:querydsl [2017/12/18 17:43] kwon37xi |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== QueryDSL ====== | ====== QueryDSL ====== | ||
* http:// | * http:// | ||
+ | * [[java: | ||
+ | * [[http:// | ||
* Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, JDO and SQL in Java. | * Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, JDO and SQL in Java. | ||
- | ====== | + | ===== Q-Types multi thread loading 시 dead lock ===== |
+ | * [[http:// | ||
+ | <code java> | ||
+ | // 미리 초기화를 호출하는게 좋다. packageToLoad 를 변경해준다. | ||
+ | ClassPathUtils.scanPackage(Thread.currentThread().getContextClassLoader(), | ||
+ | </ | ||
+ | ===== join 성능 향상 ===== | ||
+ | * Join 시 그 결과로 나오는 관계 객체를 Eager Loading 하려면 '' | ||
+ | |||
+ | <code java> | ||
+ | from(parent).innerJoin(parent.child).fetch() | ||
+ | .... | ||
+ | </ | ||
+ | |||
+ | ===== JPA QueryDSL Cross Join 발생 ===== | ||
+ | * '' | ||
+ | QParent parent = QParent.parent; | ||
+ | QChild child = parent.child; | ||
+ | |||
+ | from(parent).innerJoin(parent.child).fetch() | ||
+ | .where(parent.something.gt(parent.child.somthing))....; | ||
+ | </ | ||
+ | * 다음처럼 '' | ||
+ | QParent parent = QParent.parent; | ||
+ | QChild child = QChild.child; | ||
+ | |||
+ | from(parent).innerJoin(parent.child, | ||
+ | .where(parent.something.gt(child.somthing))....; | ||
+ | </ | ||
+ | |||
+ | ===== Native 조건 condition ===== | ||
+ | * [[http:// | ||
+ | <code java> | ||
+ | // MySQL의 TIMESTAMPDIFF를 Expression으로 만들기 | ||
+ | |||
+ | Expressions.numberTemplate(Long.class, | ||
+ | " | ||
+ | QSomething.dateField, | ||
+ | QOtherThing.anotherDateField); | ||
+ | |||
+ | // 이것을 메소드로 빼면 다음과 같은 형태가 된다. | ||
+ | public static NumberExpression< | ||
+ | Expression<? | ||
+ | Expression<? | ||
+ | return Expressions.numberTemplate(Long.class, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== 상수가 들어가는 표현식 ===== | ||
+ | * [[http:// | ||
+ | * **'' | ||
+ | <code java> | ||
+ | // 0.12 - w.totalCost 를 나타내고자 한다. | ||
+ | Expressions.operation(Float.class, | ||
+ | Expressions.constant(0.12f), | ||
+ | // or | ||
+ | NumberOperation.create(Float.class, | ||
+ | Expressions.constant(0.12f), | ||
+ | </ | ||
+ | |||
+ | ===== 복잡한 쿼리 ===== | ||
+ | * 복잡한 쿼리는 '' | ||
+ | public List< | ||
+ | QCustomer customer = QCustomer.customer; | ||
+ | HibernateQuery qry = new HibernateQuery(session).from(customer); | ||
+ | BooleanBuilder builder = new BoolenBuilder(); | ||
+ | for (String name : names){ | ||
+ | builder.or(customer.name.eq(name)); | ||
+ | } | ||
+ | qry.where(builder); | ||
+ | return qry.list(customer); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== @Embeddable의 필드 소스 생성 ===== | ||
+ | * Embeddable안에 또 다른 Embeddable이 있을 경우, 더 자식쪽 Embeddable의 경우 명시적 컬럼 매핑('' | ||
+ | * 버그로 보인다. | ||
+ | |||
+ | ==== Metamodel 생성 ==== | ||
+ | * [[gradle: | ||
+ | * [[gradle: | ||
+ | * Java 7에서 '' | ||
+ | Caused by: java.lang.NullPointerException | ||
+ | at com.mysema.query.codegen.SimpleSerializerConfig.getConfig(SimpleSerializerConfig.java: | ||
+ | at com.mysema.query.apt.DefaultConfiguration.< | ||
+ | at com.mysema.query.apt.jpa.JPAConfiguration.< | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== 참고 | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// |