๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ–ฅ๏ธ ๋ฐฑ์—”๋“œ63

Java10๋ถ€ํ„ฐ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ 'var' ํ‚ค์›Œ๋“œ ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ๋ฅผ ๊ณต๋ถ€ํ•˜๋‹ค๊ฐ€ JavaScript์—์„œ๋‚˜ ๋ณด๋˜ var ํ‚ค์›Œ๋“œ ๋ฐœ๊ฒฌ... ๋ฐ”๋กœ GPT์™€ ๊ณต๋ถ€ ์‹œ์ž‘ํ–ˆ๋‹ค Q. ์ž๋ฐ”์—์„œ var ์‚ฌ์šฉ๊ฐ€๋Šฅํ•ด?? ๋„ค, Java 10๋ถ€ํ„ฐ var ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ์ปฌ ๋ณ€์ˆ˜์˜ ํƒ€์ž…์„ ์ž๋™์œผ๋กœ ์ถ”๋ก ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ธฐ๋Šฅ์€ "๋กœ์ปฌ ๋ณ€์ˆ˜ ํƒ€์ž… ์ถ”๋ก "์ด๋ผ๊ณ  ํ•˜๋ฉฐ, var๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด Java ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ๋ณ€์ˆ˜์˜ ํƒ€์ž…์„ ์ดˆ๊ธฐํ™”์‹์—์„œ ์œ ์ถ”ํ•ฉ๋‹ˆ๋‹ค. var์˜ ์‚ฌ์šฉ ์˜ˆ์‹œ var number = 10; // int๋กœ ์ถ”๋ก ๋จ var message = "Hello World"; // String์œผ๋กœ ์ถ”๋ก ๋จ var list = new ArrayList(); // ArrayList์œผ๋กœ ์ถ”๋ก ๋จ var๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ์˜ ์ฃผ์˜์  ๋กœ์ปฌ ๋ณ€์ˆ˜์—๋งŒ ์‚ฌ์šฉ var๋Š” ์˜ค์ง ๋ฉ”์„œ๋“œ ๋‚ด๋ถ€์—์„œ ๋กœ์ปฌ ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ• .. 2023. 11. 29.
[API] REST API ํ…Œ์ŠคํŒ… ๋„๊ตฌ Talend API Tester REST API ํ…Œ์ŠคํŠธ์— ์œ ์šฉํ•œ Chrome ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ Talend API Tester [์„ค์น˜๋ฐฉ๋ฒ•] 1. Chrome์›น์Šคํ† ์–ด ๋ฐฉ๋ฌธ 2. Talend API Tester ๊ฒ€์ƒ‰ ๋ฐ ์„ค์น˜ 3. ๋น ๋ฅธ ์‚ฌ์šฉ์„ ์œ„ํ•ด ๊ณ ์ • 4. ๊ถŒํ•œ ๋ถ€์—ฌ ํ—ค๋” ์ „์†ก ๋“ฑ ๋‹ค์–‘ํ•œ ์ž‘์—… ๊ฐ€๋Šฅํ•จ 2023. 11. 29.
[API] API ๊ณ ๊ธ‰ ์„ค๊ณ„ - ์ง€์—ฐ ๋กœ๋”ฉ๊ณผ ์กฐํšŒ ์„ฑ๋Šฅ ์ตœ์ ํ™” โŒ ์—”ํ‹ฐํ‹ฐ ์ง์ ‘ ๋…ธ์ถœ @GetMapping("/api/v1/orders") public List ordersV1() { List all = orderRepository.findAll(); for (Order order : all) { order.getMember().getName(); //Lazy ๊ฐ•์ œ ์ดˆ๊ธฐํ™” order.getDelivery().getAddress(); //Lazy ๊ฐ•์ œ ์ดˆ๊ธฐํ™” List orderItems = order.getOrderItems(); orderItems.stream().forEach(o -> o.getItem().getName()); //Lazy ๊ฐ•์ œ ์ดˆ๊ธฐํ™” } return all; } order member ์™€ order address ๋Š” ์ง€์—ฐ ๋กœ๋”ฉ์ด๋‹ค. ๋”ฐ๋ผ์„œ ์‹ค์ œ ์—”.. 2023. 11. 28.
[JPA] ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ ์–ธ์–ด - ์ค‘๊ธ‰ ๋ฌธ๋ฒ•(2) JPQL - ํŽ˜์น˜ ์กฐ์ธ(fetch join) ์‹ค๋ฌด์—์„œ ์ •๋ง์ •๋ง ์ค‘์š”ํ•จ ํŽ˜์น˜ ์กฐ์ธ(fetch join) SQL ์กฐ์ธ ์ข…๋ฅ˜X JPQL์—์„œ ์„ฑ๋Šฅ ์ตœ์ ํ™”๋ฅผ ์œ„ํ•ด ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ ์—ฐ๊ด€๋œ ์—”ํ‹ฐํ‹ฐ๋‚˜ ์ปฌ๋ ‰์…˜์„ SQL ํ•œ ๋ฒˆ์— ํ•จ๊ป˜ ์กฐํšŒํ•˜๋Š” ๊ธฐ๋Šฅ join fetch ๋ช…๋ น์–ด ์‚ฌ์šฉ ํŽ˜์น˜ ์กฐ์ธ ::= [ LEFT [OUTER] | INNER ] JOIN FETCH ์กฐ์ธ๊ฒฝ๋กœ ์—”ํ‹ฐํ‹ฐ ํŽ˜์น˜ ์กฐ์ธ ํšŒ์›์„ ์กฐํšŒํ•˜๋ฉด์„œ ์—ฐ๊ด€๋œ ํŒ€๋„ ํ•จ๊ป˜ ์กฐํšŒ(SQL ํ•œ ๋ฒˆ์—) SQL์„ ๋ณด๋ฉด ํšŒ์› ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ํŒ€(T.*)๋„ ํ•จ๊ป˜ SELECT [JPQL] select m from Member m join fetch m.team select์ ˆ์— m๋งŒ ๋ช…์‹œํ•จ join fetch ๊ตฌ๋ฌธ ์‚ฌ์šฉ [SQL] SELECT M.*, T.* FROM MEMBER M INNER.. 2023. 11. 27.
[JPA] ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ ์–ธ์–ด - ์ค‘๊ธ‰ ๋ฌธ๋ฒ•(1) ๊ฒฝ๋กœ ํ‘œํ˜„์‹ .(์ )์„ ์ฐ์–ด ๊ฐ์ฒด ๊ทธ๋ž˜ํ”„๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๊ฒƒ select m.username -> ์ƒํƒœ ํ•„๋“œ from Member m join m.team t -> ๋‹จ์ผ ๊ฐ’ ์—ฐ๊ด€ ํ•„๋“œ join m.orders o -> ์ปฌ๋ ‰์…˜ ๊ฐ’ ์—ฐ๊ด€ ํ•„๋“œ where t.name = 'ํŒ€A' ๋‚ด๋ถ€์ ์œผ๋กœ ๋™์ž‘ํ•˜๋Š” ๋ฐฉ์‹ ๊ตฌ๋ถ„ ์ƒํƒœํ•„๋“œ ๋‹จ์ผ ๊ฐ’ ์—ฐ๊ด€ํ•„๋“œ ์ปฌ๋ ‰์…˜ ๊ฐ’ ์—ฐ๊ด€ํ•„๋“œ ๊ฒฝ๋กœ ํ‘œํ˜„์‹ ์šฉ์–ด ์ •๋ฆฌ ๋ฐ ์„ค๋ช… ์ƒํƒœ ํ•„๋“œ(state field) ๋‹จ์ˆœํžˆ ๊ฐ’์„ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ํ•„๋“œ (ex: m.username) ๊ฒฝ๋กœ ํƒ์ƒ‰์˜ ๋, ํƒ์ƒ‰X #๋‹จ์ผ ๊ฐ’ ์—ฐ๊ด€ ๊ฒฝ๋กœ ํƒ์ƒ‰ [JPQL] select o.member from Order o; [SQL] select m.* from Orders o inner join Member m on o.member_id .. 2023. 11. 26.
[JPA] ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ ์–ธ์–ด - ๊ธฐ๋ณธ๋ฌธ๋ฒ• (2) ์กฐ์ธ ๋‚ด๋ถ€ ์กฐ์ธ SELECT m FROM Member m [INNER] JOIN m.team t ์™ธ๋ถ€ ์กฐ์ธ SELECT m FROM Member m LEFT [OUTER] JOIN m.team t ์„ธํƒ€ ์กฐ์ธ SELECT count(m) FROM Member m, Team t WHERE m.username = t.name ON ์ ˆ ON์ ˆ์„ ํ™œ์šฉํ•œ ์กฐ์ธ(JPA 2.1๋ถ€ํ„ฐ ์ง€์›) 1. ์กฐ์ธ ๋Œ€์ƒ ํ•„ํ„ฐ๋ง 2. ์—ฐ๊ด€๊ด€๊ณ„ ์—†๋Š” ์—”ํ‹ฐํ‹ฐ ์™ธ๋ถ€ ์กฐ์ธ(ํ•˜์ด๋ฒ„๋„ค์ดํŠธ 5.1๋ถ€ํ„ฐ) ์กฐ์ธ ๋Œ€์ƒ ํ•„ํ„ฐ๋ง ์˜ˆ) ํšŒ์›๊ณผ ํŒ€์„ ์กฐ์ธํ•˜๋ฉด์„œ, ํŒ€ ์ด๋ฆ„์ด A์ธ ํŒ€๋งŒ ์กฐ์ธ [JPQL] SELECT m, t FROM Member m LEFT JOIN m.team t on t.name = 'A' [SQL] SELECT m.*, t.* FROM Me.. 2023. 11. 26.
[JPA] ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ ์–ธ์–ด - ๊ธฐ๋ณธ๋ฌธ๋ฒ• (1) JPQL Java Persistence Query Language ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ ์–ธ์–ด. ํ…Œ์ด๋ธ” ๋Œ€์ƒX ์—”ํ‹ฐํ‹ฐ ๊ฐ์ฒด๋ฅผ ๋Œ€์ƒO ์œผ๋กœ ์ฟผ๋ฆฌ SQL์„ ์ถ”์„ฑํ™”ํ•˜๋ฏ€๋กœ ํŠน์ • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค SQL์— ์˜์กดํ•˜์ง€ ์•Š์Œ ๊ฒฐ๊ตญ SQL๋กœ ๋ณ€ํ™˜ JPQL ๋ฌธ๋ฒ• select m from Member as m where m.age > 14 ์—”ํ‹ฐํ‹ฐ์™€ ์†์„ฑ์€ ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ํ•จ O(Memeber, age ๊ฐ์ฒด๊ฐ€ ๊ฐ€์ง„ ๊ฒƒ๊ณผ ๋Œ€์†Œ๋ฌธ์ž ๋™์ผํ•ด์•ผ) JPQL ํ‚ค์›Œ๋“œ๋Š” ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์Œ(SELECT select FROM from WHERE where) ์—”ํ‹ฐํ‹ฐ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•œ๋‹ค(ํ…Œ์ด๋ธ” ์ด๋ฆ„์ด ์•„๋‹˜) ๋ณ„์นญ์ด ํ•„์ˆ˜ m (as๋Š” ์ƒ๋žต ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ๊ฐ€๊ธ‰์  ์“ฐ๋ฉด ์ข‹์Œ) ์ง‘ํ•ฉ, ์ •๋ ฌ ๋“ฑ ํ•จ์ˆ˜ ๊ฐ€๋Šฅ (COUNT, SUM, AVG, MAX, GROUP BY, ORDER.. 2023. 11. 26.