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

์ „์ฒด ๊ธ€90

[ Java / querydsl ] Queryds์—์„œ์˜ ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ฐ„๋‹จํ•œ ํŽ˜์ด์ง€๋„ค์ด์…˜ - fetchResults()offset() ๋ฉ”์„œ๋“œ์™€ limit() ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ querydsl๋กœ ํŽ˜์ด์ง€๋„ค์ด์…˜์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.offset์€ ๋ช‡๋ฒˆ์งธ ํŽ˜์ด์ง€๋ฅผ ๊ฐ€์ ธ์˜ฌ์ง€, limit์€ ํ•œ ํŽ˜์ด์ง€์— ๋ช‡๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ฌ์ง€๋ฅผ ์˜๋ฏธํ•œ๋‹ค.package study.querydsl.repository;import com.querydsl.core.types.dsl.BooleanExpression;import com.querydsl.jpa.impl.JPAQueryFactory;import jakarta.persistence.EntityManager;import org.springframework.data.domain.Pageable;import org.springframework.util.Strin.. 2025. 3. 29.
[Spring / Jpa / querydsl ] ์ปค์Šคํ…€ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๊ตฌ์กฐ ์Šคํ”„๋ง ๋ฐ์ดํ„ฐ JPA์™€ querydslCustom Repository๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐSpring Data Jpa์™€ Querydsl์„ ํ™œ์šฉํ•œ custom repository(์‚ฌ์šฉ์ž ์ •์˜ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ)๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์ƒ์† ๊ตฌ์กฐ๋กœ ๊ตฌํ˜„ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.์œ„ ์‚ฌ์ง„๋ณด๋‹ค ๋” ์ง๊ด€์ ์œผ๋กœ ์ดํ•ด๊ฐ€ ์ž˜๊ฐ€๋Š” ์‚ฌ์ง„์ด ์žˆ์–ด์„œ ๊ฐ€์ ธ์™”๋‹ค.์‚ฌ์ง„ ์ถœ์ฒ˜: https://wildeveloperetrain.tistory.com/322MemberRepositoryCustom (์ธํ„ฐํŽ˜์ด์Šค)์‚ฌ์šฉ์ž ์ •์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ •์˜ํ•œ๋‹ค.package study.querydsl.repository;import org.springframework.data.jpa.repository.JpaRepository;import study.querydsl.entity.Membe.. 2025. 3. 23.
[Redis / Docker/ Error] ๋‹จ์ผ ๋ ˆ๋””์Šค์—์„œ "Connecting to MASTER [ip]:[port]" ๋กœ๊ทธ docker container๋กœ ๋„์šด redis์— ์ ‘์†ํ•ด๋ณด๋‹ˆ, ์•„๋ž˜์™€ ๊ฐ™์€ ๋กœ๊ทธ๊ฐ€ ์ฐํ˜€ ์žˆ์—ˆ๋‹ค.  ๋ญ”๊ฐ€ ์ด redis๊ฐ€ slave ๋…ธ๋“œ์ด๊ณ , master์— ์ ‘์†ํ•˜๋ ค๊ณ  ํ•˜์ง€๋งŒ ์•ˆ๋˜๊ณ  ์žˆ๋‹ค๋Š” ๋œป์ธ๊ฑฐ ๊ฐ™์€๋ฐ๋ ˆ๋””์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑํ•˜์ง€ ์•Š๊ณ  ํ•œ ๋Œ€ ์“ฐ๊ณ  ์žˆ์—ˆ๊ธฐ์— ์ €๋Ÿฐ๊ฒŒ ๋œจ๋Š”๊ฒŒ ๋„ˆ๋ฌด ์ด์ƒํ–ˆ๋‹ค ์—ด์‹ฌํžˆ ์ž๋ฃŒ๋ฅผ ์ฐพ์•„๋ด๋„ ๋ ˆ๋””์Šค ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ณผ์ •์—์„œ ์ €๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๋Š” ๊ธ€๋ฐ–์— ์ฐพ์„ ์ˆ˜ ์—†์—ˆ๋Š”๋ฐ,๊ฐ€์žฅ ์›์ธ ๊ฐ™์•„ ๋ณด์ด๋Š” stackoverflow ํŽ˜์ด์ง€๋ฅผ ํ•˜๋‚˜ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. https://stackoverflow.com/questions/57738563/redis-running-on-docker-shuts-down-after-some-time Redis running on Docker shuts down afte.. 2025. 3. 23.
[Java / querydsl] querydsl๋กœ ๋™์ ์ฟผ๋ฆฌ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋™์  ์ฟผ๋ฆฌ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” 2๊ฐ€์ง€ ๋ฐฉ๋ฒ•BooleanBuilderWhere ๋‹ค์ค‘ ํŒŒ๋ผ๋ฏธํ„ฐ ์‚ฌ์šฉ (1) BooleanBuilder ๋ฐฉ์‹BooleanBuilder๋ฅผ ๋งŒ๋“ค์–ด์„œ querydsl์˜ where์ ˆ์— ๋„ฃ์–ด์ฃผ๊ธฐ๋งŒ ํ•˜๋ฉด๋œ๋‹ค.BooleanBuilder๋ฅผ ๋งŒ๋“ค ๋•Œ, ํ•œ ์กฐ๊ฑด์ด null์ด๋ฉด ํ•ด๋‹น ์กฐ๊ฑด์„ ๋นผ๋„๋ก ๊ตฌํ˜„ํ•œ๋‹ค.๋”ฐ๋ผ์„œ usernameParam์„ null๋กœ ๋‘์—ˆ์„ ๋•Œ๋Š”, JPQL์˜ where์ ˆ์— age๋งŒ ์กด์žฌํ•˜๊ณ , @Test public void dynamicQuery_boolean_builder() { String usernameParam = null; Integer ageParam = 10; List result = searchMember1(usernamePar.. 2025. 3. 18.
[Java / querydsl] ์—ฌ๋Ÿฌ Projection ๋ฐฉ๋ฒ• ํ”„๋กœ์ ์…˜ ๊ธฐ๋ณธํ”„๋กœ์ ์…˜ ๋Œ€์ƒ์ด ํ•˜๋‚˜์ธ ๊ฒฝ์šฐ // ํ”„๋กœ์ ์…˜ ๋Œ€์ƒ์ด ํ•˜๋‚˜์ธ ๊ฒฝ์šฐ @DisplayName("๋ชจ๋“  ํšŒ์›์˜ ์ด๋ฆ„ ์กฐํšŒ") @Test void simpleProjection() { List result = queryFactory .select(member.username) .from(member) .fetch(); for (String s : result) { System.out.println("result = " + s); } }ํ”„๋กœ์ ์…˜ ๋Œ€์ƒ์ด ์—ฌ๋Ÿฌ ๊ฐœ์ธ ๊ฒฝ์šฐ @DisplayName("๋ชจ๋“  ํšŒ์›์˜ ์ด๋ฆ„๊ณผ ๋‚˜์ด๋ฅผ ๋ฐ˜ํ™˜") @Te.. 2025. 3. 16.
ํฌ์ŠคํŠธ๋งจ์œผ๋กœ Mock Server ๋งŒ๋“ค๊ธฐ(API mocking) MSA ํ”„๋กœ์ ํŠธ๋ฅผ ๊ฐœ๋ฐœํ•  ๋•Œ ๋‚ด๊ฐ€ ๊ฐœ๋ฐœํ•˜๊ณ  ์žˆ๋Š” API๊ฐ€ ๋‹ค๋ฅธ ์„œ๋ฒ„๋ฅผ ํ˜ธ์ถœํ•ด์•ผํ•œ๋‹ค๋ฉด ๊ฐœ๋ฐœ์ด๋‚˜ ํ…Œ์ŠคํŠธ ๊ณผ์ •์ด ๋ณต์žกํ•ด์งˆ ์ˆ˜ ์žˆ๋‹ค.๊ทธ๋Ÿด ๋•Œ ๋‹ค๋ฅธ ๋งˆ์ดํฌ๋กœ์„œ๋ฒ„๋ฅผ ๋กœ์ปฌ์—์„œ ๋„์›Œ๋†“๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๊ฒ ์ง€๋งŒ, ํฌ์ŠคํŠธ๋งจ์œผ๋กœ ํ•„์š”ํ•œ API๋งŒ mockingํ•œ mock ์„œ๋ฒ„๋ฅผ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.  ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜ ๋งŒ๋“ค๊ธฐ์šฐ์„  ์›Œํฌ์ŠคํŽ˜์ด์Šค ์ขŒ์ธก ์ƒ๋‹จ + ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์ƒˆ๋กœ์šด ์ปฌ๋ ‰์…˜์„ ๋งŒ๋“ค์–ด์ฃผ์ž  Mock Server ๋งŒ๋“ค๊ธฐ์šฐ์„  Mock Servers ์•„์ด์ฝ˜์ด ๋ณด์ด์ง€ ์•Š๋Š”๋‹ค๋ฉด, ํ™”๋ฉด ์ขŒ์ธก ๋ฉ”๋‰ด์ถ”๊ฐ€ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๊ณ  Mock servers๋ฅผ ๋ˆŒ๋Ÿฌ์„œ ๋ฉ”๋‰ด์— ๋ณด์ด๊ฒŒ ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค. ์—ฌ๊ธฐ๊นŒ์ง€ ๋๋‹ค๋ฉด, create mock server ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์„œ ๋ชฉ์„œ๋ฒ„๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์ž   ์ปฌ๋ ‰์…˜์€ ์œ„์—์„œ ๋งŒ๋“ค์—ˆ๋˜ ์ปฌ๋ ‰์…˜์„ ์„ ํƒํ•ด์ฃผ๊ณ ,ํ•˜๋‹จ "Save the mock.. 2025. 3. 14.