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

dev
minuk926 3 years ago
parent c3f2aa348f
commit f7116730c4

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