Today I Learned/2023

CLOB ์˜ค๋ผํด ORA-24816 ์—๋Ÿฌ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ๐Ÿง๊ฐ„ํ—์ ์œผ๋กœ๐Ÿง ๋ฐ์ดํ„ฐ ์‚ฌ์ด์ฆˆ๊ฐ€ ํด ๋•Œ, ORA-03146(๋ฒ„ํผ ๊ธธ์ด ๋ถ€์ ํ•ฉ) ์—๋Ÿฌ ๋ฐœ์ƒ ๋‚˜์˜ ๊ฒฝ์šฐ์—๋Š” INSERT, UPDATE ์‹œ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์œผ๋‚˜ MERGE๋ฌธ์—์„œ ์—๋Ÿฌ ๋ฐœ์ƒ. ๊ตฌ๊ธ€๋ง ์‹œ ๋ช…ํ™•ํ•œ ์›์ธ ๋ฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ์กด์žฌ X -> ๋Œ€์•ˆ์œผ๋กœ empty_clob()์œผ๋กœ ๋ฐ์ดํ„ฐ ์ƒ์„ฑ ํ›„ ๋”ฐ๋กœ UPDATE๋ฌธ ์ˆ˜ํ–‰์œผ๋กœ ํ•ด๊ฒฐ CUD์‹œ, CLOB์ปฌ๋Ÿผ์„ ์ œ์ผ ๋งˆ์ง€๋ง‰ ์ˆœ์„œ๋กœ ๋ณ€๊ฒฝํ–ˆ์„ ๋•Œ ํ•ด๊ฒฐ๋˜์—ˆ๋‹ค๋Š” ์ผ€์ด์Šค๋„ ์กด์žฌ ๐Ÿ‘ Reference ๋”๋ณด๊ธฐ https://velog.io/@kimbad1992/Oracle-MERGE-INTO-%EA%B5%AC%EB%AC%B8%EC%97%90%EC%84%9C%EC%9D%98-CLOB-%ED%83%80%EC%9E%85-INSERT-%EC%8B..
[@Builder] ์ƒ์†ํ•œ ํด๋ž˜์Šค์˜ ๋ฉค๋ฒ„๋„ ์‚ฌ์šฉํ•ด์„œ ๋นŒ๋” ์ƒ์„ฑํ•˜๊ธฐ @Builder ์–ด๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด, ์ƒ์†๋ฐ›์€ ํด๋ž˜์Šค์˜ ๋ฉค๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•˜๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. @Getter @AllArgsConstructor public class Parent { private final String parentName; private final int parentAge; } @Getter @Builder public class Child extends Parent { private final String childName; private final int childAge; } ์˜ˆ๋ฅผ ๋“ค์–ด, ์œ„์˜ ์ฝ”๋“œ์™€ ๊ฐ™์ด Parent๋ฅผ ์ƒ์†๋ฐ›์€ Child์˜ Builder๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•˜๋ฉด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค..
Java Switch NPE ํ”ผํ•˜๊ธฐ String str = null; switch (str) { case "one": System.out.println("1"); break; case "two": System.out.println("2"); break; default: System.out.println("default"); break; } ์œ„์™€ ๊ฐ™์€ ์ฝ”๋“œ์—์„œ switch(์กฐ๊ฑด) -> (์กฐ๊ฑด)์— ๋“ค์–ด๊ฐ€๋Š” ๋ณ€์ˆ˜๊ฐ€ null์ผ ๊ฒฝ์šฐ NPE๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ๋‹น์—ฐํ•œ ๊ฒฐ๊ณผ์ผ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ์ƒ๊ฐ๋ณด๋‹ค ๋†“์น  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์ด๋ผ ๊ธ€๋กœ ๋‚จ๊ฒจ ๋†“์œผ๋ ค๊ณ  ํ•œ๋‹ค. ๋˜ํ•œ, NPE๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ• ๋ช‡๊ฐ€์ง€๋ฅผ ์†Œ๊ฐœํ•œ๋‹ค. ์‚ฌ์‹ค ๋‹ค ์ฉ ๋ง˜์— ๋“œ๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋‹ˆ๋ผ, Pattern Matching ๊ธฐ๋Šฅ์ด ๋„์ž…๋œ switch๋ฌธ์„ ์‚ฌ์šฉ(java 17 ์ดํ›„..
[Mapstruct] LocalDateTime Date mapstruct ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด LocalDateTime์„ Date๋ฅผ ๋ฐ”๊ฟ€๋•Œ ๊ธฐ๋ณธ์ ์œผ๋กœ Timezone์„ UTC๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ํ˜„์žฌ ์„œ๋ฒ„๊ฐ€ ์กด์žฌํ•˜๋Š” ๋‚˜๋ผ์˜ ์‹œ๊ฐ„๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋ณ€ํ™˜ ๋œ๋‹ค. (์šฐ๋ฆฌ๋‚˜๋ผ์˜ ๊ฒฝ์šฐ -9์‹œ๊ฐ„ ๋œ ์‹œ๊ฐ„์œผ๋กœ ๋ณด์—ฌ์ง) ๊ทธ๋ž˜์„œ ํ˜„์žฌ ์‹œ์Šคํ…œ์˜ timezone์„ ์ด์šฉํ•ด ๋ณ€ํ™˜ํ•ด์•ผ ํ•˜๋Š”๋ฐ ๋”ฑํžˆ timezone์„ ๋ณ€์ˆ˜๋กœ ์‚ฌ์šฉํ•ด ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€ ์—†์–ด๋ณด์—ฌ์„œ, expression์„ ์ด์šฉํ•ด ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ ํƒํ–ˆ๋‹ค. import org.mapstruct.Mapper; import org.mapstruct.Mapping; import java.time.ZoneId; import java.util.List; @Mapper(imports = Z..
LocalDateTime.MIN to Date, LocalDateTime.MAX to Date -> java.lang.IllegalArgumentException: java.lang.ArithmeticException: long overflow java.util.Date ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„์•ผ ํ•˜๋Š” ์ด์œ ๊ฐ€ ์ˆ˜๋„ ์—†์ด ๋งŽ๋‹ค๋Š” ์ ์„ ์•Œ์ง€๋งŒ, ์–ด์ฉ” ์ˆ˜ ์—†์ด Date ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์—ˆ๋‹ค. (๋‚˜์˜ ๊ฒฝ์šฐ๋Š” ํšŒ์‚ฌ์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ผ์‹œ๋ฅผ ๋‹ค๋ฃฐ ๋•Œ Date๋ฅผ ์‚ฌ์šฉ์ค‘์ด๊ณ (ใ…Žใ…Ž), ๊ทธ ์™ธ์—๋„ ์ด์œ ๊ฐ€ ์žˆ์—ˆ๋‹ค) ์•„๋ฌดํŠผ, ๊ทธ๋ž˜์„œ LocalDateTime์„ Date๋กœ ๋ณ€ํ™˜ํ•˜๋‹ค๋ณด๋‹ˆ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ด ์ด๋ฅผ ๊ณต์œ ํ•˜๊ณ ์ž ํ•œ๋‹ค. ๐Ÿ“’ LocalDate(LocalDateTime) to Date // Timestamp์˜ value..
YURI๐Ÿ•๐Ÿ“๐Ÿถ
'Today I Learned/2023' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก