querydsl 적용(rebuild시 에러 발생하는것 fix)

dev
minuk926 3 years ago
parent c3f2aa348f
commit f7116730c4

@ -306,35 +306,47 @@ tasks.withType(JavaCompile) {
// querydsl // querydsl
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//
def querydslDir = "$buildDir/generated" def querydslDir = "$buildDir/generated"
querydsl {
jpa = true // querydsl
querydslSourcesDir = querydslDir
}
sourceSets { sourceSets {
main { main {
java { java {
//srcDirs = ["$projectDir/src/main/java", querydslDir] srcDirs = ["$projectDir/src/main/java", querydslDir]
srcDir querydslDir }
} }
} }
querydsl {
jpa = true
querydslSourcesDir = querydslDir
} }
configurations { configurations {
compileOnly { compileOnly {
extendsFrom annotationProcessor extendsFrom annotationProcessor
} }
querydsl.extendsFrom compileClasspath querydsl.extendsFrom compileClasspath
} }
compileQuerydsl { compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl options.annotationProcessorPath = configurations.querydsl
} }
// build querydsl
compileQuerydsl.doFirst {
if(file(querydslDir).exists())
delete(file(querydslDir))
}
// build querydsl
compileJava { compileJava {
options.compilerArgs << '-s' options.compilerArgs << '-s'
options.compilerArgs << "$buildDir/generated/" options.compilerArgs << "$buildDir/generated/"
doFirst { doFirst {
delete(files("${buildDir}/generated/")) if(file(querydslDir).exists())
file(new File(buildDir, '/generated/')).mkdirs(); delete(file(querydslDir))
file(querydslDir).mkdirs();
} }
} }
//-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------//

@ -0,0 +1,57 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.biz.ctgy.entity.MinSimsa680;
import com.xit.biz.ctgy.entity.QMinSimsa680;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
@Slf4j
public class RepositoryTest {
@Autowired
EntityManager em;
private JPAQueryFactory queryFactory;
// @BeforeAll
// void beforeAll(){
// log.debug("initializing...");
// }
// @AfterAll
// void afterAll(){
// log.debug("...shutdown");
// }
@BeforeEach
void beforeEach(){
log.debug("biz start...");
queryFactory = new JPAQueryFactory(em);
}
@AfterEach
void afterEach(){
log.debug("... biz end");
}
@Test
void querydslTest() {
//QMinSimsa680 qMinSimsa680 = new QMinSimsa680("minSimsa680");
MinSimsa680 simsa680 = queryFactory.selectFrom(minSimsa680)
.where(minSimsa680.msMaincode.eq(300297013L))
.fetchOne();
log.debug("##################################{}",simsa680);
}
}
Loading…
Cancel
Save