본문 바로가기

분류 전체보기155

QueryDSL 조인 예제 Inner Join QCustomer customer = QCustomer.customer; QCompany company = QCompany.company; queryFactory.select(customer.firstName, customer.lastName, company.name) .from(customer) .innerJoin(customer.company, company) .fetch(); Left Join queryFactory.select(customer.firstName, customer.lastName, company.name) .from(customer) .leftJoin(customer.company, company) .fetch(); 다음과 같이 SQL처럼 on을 사용해서 조인 조.. 2019. 6. 5.
Java 시스템 운영체제 정보 출력하기 Java 애플리케이션이 현재 동작하고 있는 시스템 운영체제 정보 출력하기 위해서는 System.getProperty("os.name") 코드를 사용하면 된다. 프로퍼티에서 가져온 정보를 기반으로 조건문을 사용해서 OS를 구분한다. public class SystemOsMain { public static void main(String[] args) { String os = System.getProperty("os.name").toLowerCase(); if (os.contains("win")) { System.out.println("Windows"); } else if (os.contains("mac")) { System.out.println("Mac"); } else if (os.contains("ni.. 2019. 6. 4.
Spring Core 라이브러리 이용해서 Properties 파일 데이터 읽기 public class Main { public static void main(String[] args) throws Exception { Resource resource = new ClassPathResource("custom.properties"); // 1 Properties properties = PropertiesLoaderUtils.loadProperties(resource); // 2 System.out.println(properties); // 3 } } 1. custom.properties 파일 데이터를 가져와서 Resource 객체로 캐스팅 2. PropertiesLoaderUtils 유틸 클래스를 이용해서 Properties 객체로 변환 3. properties 객체 내용 출력 2019. 5. 28.
Moment 타임존 값에 따라 날짜 포맷팅 출력 const today = moment().lang("ko").format('LLL'); console.log(today); 참고자료 https://momentjs.com/timezone/docs/ 2019. 5. 24.
리팩토링 - 메서드 정리 메서드 추출 (Extract Method) 어떤 코드를 그룹으로 묶어도 된다고 판단이 들면, 해당 코드들을 빼내어 목적을 잘 나타내는 메서드로 만들자 수정전 코드 public void printOwing(double previousAmount) { System.out.println("****************"); System.out.println("*****고객 외상****") System.out.println("****************"); double outstanding = previousAmount * 1.2; for (Order o : orders) { outstanding += o.getAmount(); } System.out.println("name: " + name); Syste.. 2019. 5. 16.
MySQL "Cannot get geometry object from data you send to the GEOMETRY field" 에러 해결방법 임시 테이블 생성 id, geometry 두 개의 컬럼을 구성된 테이블을 생성한다. CREATE TABLE `geo_test` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `geo` geometry DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 테이블에 geometry 타입 데이터 추가 (에러 발생) 아래 SQL 구문을 실행하면 "Cannot get geometry object from data you send to the GEOMETRY field" 에러가 발생한다. geometry 필드에 텍스트 값을 넣으려고 했기 때문에 발생한 에러이다. INSER.. 2019. 5. 13.