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

dev
minuk926 3 years ago
parent 7e54779ea8
commit 76c501fe24

@ -3,8 +3,10 @@ package com.xit.core.util;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
@ -18,6 +20,28 @@ import java.util.Date;
public class DateUtil {
public static java.util.Date toDateFromLocalDate(LocalDate localDate){
Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
//return java.sql.Date.valueOf(localDate);
}
public static java.util.Date toDateFromLocalDateTime(LocalDateTime localDateTime){
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
//return java.sql.Timestamp.valueOf(localDateTime);
}
public static LocalDate toLocalDateFromDate(Date date){
return LocalDate.ofInstant(date.toInstant(), ZoneId.systemDefault());
//return new java.sql.Date(date.getTime()).toLocalDate();
}
public static LocalDateTime toLocalDateTimeFromDate(Date date){
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
//return new java.sql.Timestamp(date.getTime()).toLocalDateTime();
}
/**
* LocalDate
*

@ -1,32 +1,80 @@
package com.xit.biz.ctgy.repository;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.xit.core.util.DateUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
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 java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static com.xit.biz.ctgy.entity.QMinSimsa680.minSimsa680;
import static com.xit.biz.ctgy.entity.QMinSimsaUser680.minSimsaUser680;
import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
@Transactional
@ActiveProfiles({"dev"})
class IMinSimsa680RepositoryTest {
@Autowired
private IMinSimsa680Repository iMinSimsa680Repository;
EntityManager em;
private JPAQueryFactory queryFactory;
@Autowired
private JPAQueryFactory jpaQueryFactory;
private IMinSimsa680Repository iMinSimsa680Repository;
@BeforeEach
void beforeEach(){
queryFactory = new JPAQueryFactory(em);
}
@AfterEach
void afterEach(){
}
@Test
@DisplayName("wwwww")
void findMinSimsa680s2() {
@DisplayName("sim_result:심사목록에서 기간 클릭시")
void sim_result() {
//LocalDate now = LocalDate.now();
LocalDate now = LocalDate.of(2021, 12, 11);
LocalDate now2 = LocalDate.of(2021, 12, 12);
queryFactory
.select(minSimsa680.msSeq,
minSimsa680.msCarnum,
minSimsa680.msMaincode)
.from(minSimsaUser680)
.join(minSimsa680)
.on(minSimsa680.msMaincode.eq(minSimsaUser680.msuMaincode))
.join(minUserinfo)
.on(minSimsaUser680.msuUserid.eq(minUserinfo.userid))
.where(minSimsaUser680.msuTeam.eq(""),
minSimsa680.msChasu.eq(1L),
minSimsa680.msSdate.eq(java.sql.Date.valueOf(now)),
minSimsa680.msEdate.eq(java.sql.Date.valueOf(now2)))
.groupBy(minSimsa680.msCarnum,
minSimsa680.msSeq,
minSimsa680.msMaincode)
.orderBy(minSimsa680.msSeq.asc())
.offset(0L)
.limit(10L)
//, minSimsa680.msSdate.eq(java.sql.Date.valueOf(now)))
.fetchResults();
// jpaQueryFactory.selectFrom(minSimsa680)
// .leftJoin(minSimsa680.msMaincode, minSimsaUser680).fetchJoin()
// .groupBy(minSimsa680.msEdate, minSimsaUser680.msuTeam, qMinUserinfo.name)
@ -36,4 +84,14 @@ class IMinSimsa680RepositoryTest {
}
// @BeforeAll
// void beforeAll(){
// log.debug("initializing...");
// }
// @AfterAll
// void afterAll(){
// log.debug("...shutdown");
// }
}

@ -52,6 +52,6 @@ public class RepositoryTest {
MinSimsa680 simsa680 = queryFactory.selectFrom(minSimsa680)
.where(minSimsa680.msMaincode.eq(300297013L))
.fetchOne();
log.debug("##################################{}",simsa680);
System.out.println("##################################"+simsa680);
}
}

Loading…
Cancel
Save