2023/01 4

Criteria API

Goal Criteria API CriteriaBuilder CriteriaQuery Criteria API Java Persistence Criteria API ๋Š” JPQL ์˜ ๋ฌธ์ž์—ด ๊ธฐ๋ฐ˜ ์ ‘๊ทผ ๋ฐฉ์‹์„ ์ด์šฉํ•˜๋Š” ๋Œ€์‹  ๊ฐ์ฒด ๊ธฐ๋ฐ˜ ์ฟผ๋ฆฌ ์ •์˜ ๊ฐœ์ฒด์˜ ๊ตฌ์„ฑ์„ ํ†ตํ•ด ๋™์  ์ฟผ๋ฆฌ๋ฅผ ์ •์˜ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋œ๋‹ค. Critera API ์—๋Š” type-restricted mode, non-typed mode ๋กœ ๋‚˜๋‰˜๋ฉฐ, ๋Ÿฐํƒ€์ž„ ์‹œ ๋™์ ์œผ๋กœ ์กฐํšŒ ๋นŒ๋“œ๋ฅผ ์ง€์›ํ•ด ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ๊ฒ€์ฆํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. ๋˜ํ•œ Criteria API ๋Š” ๋™์  ์ฟผ๋ฆฌ์—๋งŒ ์‚ฌ์šฉ๋˜์–ด ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋˜๋Š” Named Query ์—์„œ๋Š” ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์œผ๋ฉฐ ๋™์  ์ฟผ๋ฆฌ์—์„œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด ๊ธฐ์กด์˜ ์ •์  Named Query ์— ๋น„ํ•ด ์„ฑ๋Šฅ์ด ๋›ฐ์–ด๋‚˜์ง€ ์•Š๋‹ค. ๊ทธ๋Ÿฌํ•œ ์ด์œ ๋กœ JPA ..

Programming/Spring 2023.01.28

Spring Bean / IoC Container / DI

Goal Spring Bean Spring IoC Container Dependency Injection (DI) Constructor Injection Method Injection Setter Injectio Spring Bean Spring Bean ์œผ๋กœ ๋“ฑ๋ก๋œ ํด๋ž˜์Šค๋Š” IoC Contrainer ์— ์˜ํ•ด ์ƒ์„ฑ๋œ Singleton ๊ฐ์ฒด๋ฅผ ์˜๋ฏธํ•˜๋ฉฐ, Bean ์œผ๋กœ ๋“ฑ๋ก๋œ ํด๋ž˜์Šค๋งŒ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ†ตํ•ด ์˜์กด์„ฑ์ด ์ฃผ์ž…(Dependency Injection)๋˜์–ด ๊ฐ์ฒด์˜ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ๊ฐœ๋ฐœ์ž๊ฐ€ ์•„๋‹Œ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๊ด€๋ฆฌํ•˜๋„๋ก ํ•œ๋‹ค. Register Bean @Bean @Bean ์€ @Configuration ์ด ๋ถ™์€ DI ์„ค์ •์šฉ ํด๋ž˜์Šค์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ, ๋ฉ”์†Œ๋“œ๋ฅผ ์ด์šฉํ•ด Bean Object ์˜ ์ƒ์„ฑ๊ณผ ์˜์กด ๊ด€๊ณ„..

Programming/Spring 2023.01.21

2022

๋งˆ๋ฌด๋ฆฌํ•˜๋ฉฐ 2022๋…„์ด ์ €๋ฌผ๊ณ  2023๋…„์ด ๋ฐ์•˜๋‹ค. ์–ด์ œ ์ €๋ฌธ ํ•ด์™€ ์˜ค๋Š˜ ๋ฐ์€ ํ•ด๋Š” ๊ฐ™์€ ํƒœ์–‘์ธ๋ฐ 12์›” 31์ผ๋งŒ ๋˜๋ฉด ์™œ ๊ทธ๋ ‡๊ฒŒ ๋งˆ์Œ ํ•œ ๊ณณ์ด ์•„๋ฆฐ์ง€. ์•„๋งˆ๋„ ๋– ๋‚œ ์ด๋ฅผ ์žŠ์ง€ ๋ชปํ•ด์„œ ์ผ์ง€๋„ ํ˜น์€ ์ง€๊ธˆ ๋‚ด ๊ณ์— ์žˆ๋Š” ์ด๋“ค์„ ์ง„์‹ฌ ๋‹คํ•ด ์‘์›ํ•ด์„œ ์ผ์ง€๋„ ๋ชจ๋ฅด๊ฒ ๋‹ค. ๋‚˜์—๊ฒŒ 2022๋…„์€ ์—ฌ๋Ÿฌ ์˜๋ฏธ๋กœ ๋‹ค์ฑ„๋กœ์šด ์‹œ๊ฐ„๋“ค์˜ ์—ฐ์†์ด์—ˆ๋‹ค. ๊ตฌ๊ตฌ์ ˆ์ ˆ, ์‹œ์‹œ์ฝœ์ฝœ, ํ˜น์€ ์ฃผ์ฑ…๋งž์€ ์ด์•ผ๊ธฐ์ผ์ง€๋„ ๋ชจ๋ฅด์ง€๋งŒ ๋‚ด๊ฒŒ๋Š” ๋„ˆ๋ฌด ๋‹ค์ฑ„๋กœ์šด ์‹œ๊ฐ„๋“ค์ด์—ˆ๋‹ค. ๋งŽ์ด ์•„ํŒ ๊ณ , ์•„ํ””์„ ๊ฒฌ๋”œ ์ˆ˜ ์—†์–ด ๋งŽ์ด ์šธ์—ˆ๊ณ , ์ƒˆ๋กœ์šด ์‚ฌ๋žŒ๋“ค์„ ๋งŒ๋‚ฌ๊ณ , ์—ฌ์ „ํžˆ ๋‚ด ๊ณ์„ ๋งด๋„๋Š” ์‚ฌ๋žŒ๋“ค ๋•๋ถ„์— ์•„ํ””์˜ ๋ฐฐ๋กœ ์›ƒ๊ณ  ํ–‰๋ณตํ•˜๊ธฐ๋„ ํ–ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ˆ ๋„ ๋งŽ์ด ๋Š˜์—ˆ๊ณ . ์„ธ์ƒ์€ ์ •๋ง ๋น ๋ฅด๊ฒŒ ๊ธ‰๋ณ€ํ•˜๋ฉด์„œ ์‚ฌ๊ฑด์‚ฌ๊ณ ๋„ ๋งŽ์ด ์ผ์–ด๋‚˜๊ณ  ์žˆ๋‹ค. ์˜ฌํ•ด๋Š” ๋งˆ์Œ ์•„ํ”ˆ ์ผ๋“ค์ด ๋งŽ์•˜๋‹ค. ์—ฌ์ „ํžˆ ๊ทธ๋“ค์˜ ๋งˆ์Œ์€ ์น˜..

JPA / Persistence Context / Transactional

Goal JDBC Spring Data JPA Persistence Context JDBC? Spring JDBC ๋ž€ Spring Framework ์™€ DB ๊ฐ„ ํ†ต์‹ ์„ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋กœ ๊ฐœ๋ฐœ์ž๊ฐ€ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” ๋ฒค๋”์‚ฌ์˜ ์ œํ’ˆ์— ๊ด€๊ณ„์—†์ด DB ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ด์ค€๋‹ค. ํ•˜์ง€๋งŒ JDBC ๋Š” Persistence Layer ์™€ ๊ธด๋ฐ€ํ•œ ๊ด€๊ณ„๋ฅผ ๋งบ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ๋ฐœ์ž๊ฐ€ ์ง์ ‘ Connection ์„ค์ •ํ•˜๊ฑฐ๋‚˜ Statement ๋ฅผ ์ด์šฉํ•ด ์›ํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ ํ›„ Statement ๋ฅผ ์ง์ ‘ ๋‹ซ์•„์ค˜์•ผ ํ•˜๋Š” ๋“ฑ์˜ ๋ฌธ์ œ์ ์ด ์•ผ๊ธฐ๋  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ค‘๋ณต ์ฝ”๋“œ์˜ ์žฌ์ƒ์‚ฐ์œผ๋กœ ์ธํ•ด ์œ ์ง€๋ณด์ˆ˜์˜ ๋‚œ์ด๋„๊ฐ€ ์ƒ์Šนํ•˜๊ฒŒ ๋œ๋‹ค. Spring Data JPA ORM(Object Relation Mapper) ์ค‘ ํ•˜๋‚˜๋กœ, ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ Java ์˜ ๊ฐ..

Programming/Spring 2023.01.14