본문 바로가기

전체 글236

Java8 비동기 처리 예제 public List retrieveYcvsSsevntList(String svcTypeCd, String strCd, String custNo, String sessnId) { // 기획전 목록 조회 List sseventList = this.ycvsSseventGsmcMapper.retrieveYcvsSsevntList(svcTypeCd, strCd, custNo, sessnId); if (sseventList == null || sseventList.isEmpty()) { return null; } List> asyncSseventList = new ArrayList(); for (YcvsSsevntInf.. 2024. 9. 13.
[Java] toString() 공통 오버라이드 라이브러리를 안써서 직접 구현 package com.gsr.base;import java.lang.reflect.Field;import java.util.ArrayList;import java.util.Arrays;import java.util.List;import java.util.stream.Collectors;public class CmmUtils { /** * 배열을 입력받아 리스트로 리턴한다. * * @param s 동적 배열 */ @SafeVarargs public static List listOf(T... s) { if(s == null) { return new ArrayList(); } return Arrays.stream(s).collect(Collectors.toLis.. 2024. 6. 5.
[JAVA] Thread-safe collections(동기화된 콜렉션 선언) 리스트 private List forceInsertItemCdList = Collections.synchronizedList(new ArrayList()); 내부 코드 /** * Returns a synchronized (thread-safe) list backed by the specified * list. In order to guarantee serial access, it is critical that * all access to the backing list is accomplished * through the returned list. * * It is imperative that the user manually synchronize on the returned * list when itera.. 2024. 2. 15.
[Spring] QuartzJobBean 으로 스케쥴러 등록 및 사용 매번 까먹어서 기록 1. pom.xml에 라이브러리 추가 https://mvnrepository.com/artifact/org.quartz-scheduler/quartz QuartzJobBean을 상속받은 Job 클래스 구현 /** *스케쥴 Job 실행 클래스 */ public class CloudJobExecutor extends QuartzJobBean { @Override protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { // TODO Auto-generated method stub // 실제 수행할 로직.. } } Spring-Quartz 설정(context-quartz.xml) - 버젼별로.. 2024. 1. 10.
Redshift 최근 실행 쿼리 확인 방법 아래 쿼리로 최근 100개의 실행 쿼리를 확인할 수 있다. select * from stl_query order by stl_query.starttime desc limit 100 ; 실행하면 이러한 정보를 얻을 수 있다. 2023. 11. 29.
[Querydsl] Where 절에 case문 사용 querydsl에서도 where절에 case문 사용이 가능하다. 아래처럼 사용한다. 보통 동적으로 조건을 나눠 걸어야할 때 사용하기 때문에, 내 경우는 아예 조건문을 생성하는 기능을 따로 구현하도록 했다. BooleanBuilder 앞뒤에 얼마든지 추가 조건을 붙일 수 있다. BooleanBuilder conditions = new BooleanBuilder(); if (addYn.isSuppCd() && noneNull(this.suppCd, params.getSuppCd())) { // 조건이 true일 경우 in절을 조건절에 넣고 false일 경우 1=1 을 넣어 pass 시킨다. conditions.and(new CaseBuilder().when(params.getCorpRegNo().eq(thi.. 2023. 11. 28.
[AWS RedShift] querydsl 레드시프트에서 나눗셈 때 소수점 표기 올바르게 하는 방법 2가지 레드시프트에서 나눗셈을 하면 정수로 떨어지거나 특정 자리에서 버림처리 해버리는 경우가 발생한다. 이유는, 나눗셈할 때 정수/정수 로 들어왔을 경우 나눗셈 결과가 정수로 떨어지기 때문이다. 해결 방법은 숫자를 분명하게 정수가 아니도록 만들어주는 것이다. 쿼리로 던질 경우는 소수점 처리를 하면 되지만 Querydsl 등에서 파라미터로 던질 때는 아래와 같이 한다. 아래와 같은 식으로 함수를 구성한다고 하면 분모와 분자를 던질 때 1.0을 곱해서 던진다. multiply를 Double형으로 던져도 원하는 결과는 나오지 않는다. public static NumberTemplate divideAndMultiplyAndRound(Integer scale, Integer multiply, Object... args).. 2023. 11. 7.
[Querydsl] Querydsl에서 groupBy에 substring 사용 불가 원인을 확실하게는 모르겠으나, 일반 query 작성 시에는 group by 절에 substring(redshift 함수명 기준)으로 자른 것도 사용 가능하나 querydsl에서는 불가능하다. 위와 같이 세팅후 실행하면 이렇게..!!! 되지 않는다. 레드시프트에서 일반 쿼리문으로는 문제 없는 것을 보면 레드시프트에서 지원하는 라이브러리에서 문제가 있는 것 같은데... 그런 거면 답이 없다. 2023. 9. 22.
모든 HTML 태그 제거하는 정규식 String regex = "]*>?";// 모든 HTML 태그 제거하는 정규식 String html = "~~~나나나나누나나나"; println(html.replaceAll(regex, ""); >> ~~~나나나나누나나나 2023. 5. 18.