(querydsl 관련 부분만 남겨둠)
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}
plugins {
...
id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}
...
dependencies {
...
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
}
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
...
1. Gradle 탭을 들어간다
2. Tasks->other->compileQuerydsl
3. Run
Q클래스 생성!
QCustomer customer = QCustomer.customer;
JPAQuery<?> query = new JPAQuery<Void>(entityManager);
Customer bob = query.select(customer)
.from(customer)
.where(customer.firstName.eq("Bob"))
.fetchOne();