๋ณธ ํฌ์คํ ์ ๋ฐฑ๊ธฐ์ ๋์ ์คํ๋ง๊ณผ JPA ๊ธฐ๋ฐ ์น ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํ์ฌ ์์ฑํ์์ต๋๋ค. ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. (commit hash: f39b053) > git clone https://github.com/lcalmsky/spring-boot-app.git > git checkout f39b053 โน๏ธ squash merge๋ฅผ ์ฌ์ฉํด ๊ธฐ์กด branch๋ฅผ ์ญ์ ํ๊ธฐ๋ก ํ์ฌ ์์ผ๋ก๋ commit hash๋ก ํฌ์คํ ์์ ์ ์์ค ์ฝ๋๋ฅผ ๊ณต์ ํ ์์ ์ ๋๋ค. Overview ์คํฐ๋ ๊ฒ์ ๊ธฐ๋ฅ์ ๊ตฌํํฉ๋๋ค. ํค์๋๋ฅผ ์ ๋ ฅ ๋ฐ์ ์คํฐ๋๋ฅผ ๊ฒ์ํ๋๋ฐ, ์คํฐ๋ ์ ๋ชฉ, ๊ด์ฌ์ฌ, ๋์ ์ด๋ฆ์ด ํค์๋์ ํด๋นํฉ๋๋ค. ๋ก๊ทธ์ธํ์ง ์๊ณ ๋ ์ฌ์ฉํ ์ ์์ด์ผ ํฉ๋๋ค. ๊ฒ์์ผ๋ก ๋ณด์ฌ์ง ๋ด์ฉ์ ์๋์ ๊ฐ์ต๋๋ค. ๊ฒ์ ํค์๋..
๋ณธ ํฌ์คํ ์ ๋ฐฑ๊ธฐ์ ๋์ ์คํ๋ง๊ณผ JPA ๊ธฐ๋ฐ ์น ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํ์ฌ ์์ฑํ์์ต๋๋ค. ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. (commit hash: dc5c662) > git clone https://github.com/lcalmsky/spring-boot-app.git > git checkout dc5c662 โน๏ธ squash merge๋ฅผ ์ฌ์ฉํด ๊ธฐ์กด branch๋ฅผ ์ญ์ ํ๊ธฐ๋ก ํ์ฌ ์์ผ๋ก๋ commit hash๋ก ํฌ์คํ ์์ ์ ์์ค ์ฝ๋๋ฅผ ๊ณต์ ํ ์์ ์ ๋๋ค. Overview ์คํฐ๋ ์์ฑ ํ ๊ณต๊ฐํ ๋ ์๋ฆผ์ ์ ์กํฉ๋๋ค. ์๋ฆผ ๋ฐ์ ๋์: ์คํฐ๋ ์ฃผ์ ์ ์ง์ญ์ ๋งค์นญ๋๋ ์ฌ์ฉ์ ์๋ฆผ ์ ๋ชฉ: ์คํฐ๋ ์ด๋ฆ ์๋ฆผ ๋ฉ์์ง: ์คํฐ๋ ์งง์ ์๊ฐ ์๋น์ค ์์ ์ง๋ ๋ฒ์ ์คํฐ๋๊ฐ ์์ฑ๋ ๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ์์์ผฐ๋ ๋ถ๋ถ์..
๋ณธ ํฌ์คํ ์ ๋ฐฑ๊ธฐ์ ๋์ ์คํ๋ง๊ณผ JPA ๊ธฐ๋ฐ ์น ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ๋ฐ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํ์ฌ ์์ฑํ์์ต๋๋ค. ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. (commit hash: 37f3309) > git clone https://github.com/lcalmsky/spring-boot-app.git > git checkout 37f3309 โน๏ธ squash merge๋ฅผ ์ฌ์ฉํด ๊ธฐ์กด branch๋ฅผ ์ญ์ ํ๊ธฐ๋ก ํ์ฌ ์์ผ๋ก๋ commit hash๋ก ํฌ์คํ ์์ ์ ์์ค ์ฝ๋๋ฅผ ๊ณต์ ํ ์์ ์ ๋๋ค. Overview ์์ผ๋ก ์ฌ์ฉํ๊ฒ ๋ querydsl์ ์ค์ ํฉ๋๋ค. build.gradle ์์ plugins { // ์๋ต id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10&..
์ด๋ฒ์ 5.0.0 ๋ฒ์ ์ด release ๋์๋๋ฐ ์ด๋ค ๋ณ๊ฒฝ์ฌํญ์ด ์์๋์ง ์ดํด๋ณด๊ฒ ์ต๋๋ค. ๐ ๋จผ์ ๊ฐ์ฅ ํฐ ๋ณํ๋ ์๋ฐ 8๋ฒ์ ๋ฏธ๋ง์ ์ด์ ์ง์ํ์ง ์๋ ๊ฒ ์ธ๋ฐ์, ์๋ฐ 7๋ฒ์ ์ดํ๋ฅผ ์ฌ์ฉํ๋ ๋ถ๋ค์ 4.x.x ๋ฒ์ ์ ๊ณ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ joda-time๊ณผ google์ guava ๋ฐํ์ dependency๋ฅผ ์ ์ธํ์์ต๋๋ค. ์ด๋ฒ ์ ๋ฐ์ดํธ๋ ์ฝ 2๋ ๋ง์ ์ด๋ฃจ์ด์ง ๋ฉ์ด์ ์ ๋ฐ์ดํธ๋ก ๊ทธ๋์ github์ ๋จ๊ฒจ์ง ์ด์ ์ค ๋น์ค์๋ ๊ฒ๋ค ์์ฃผ๋ก ์ฒ๋ฆฌํ๋ค๊ณ ํฉ๋๋ค. ํผ์ง๋ง ํ ๊ฒ๋ค์ ๊ฐ๋จํ ์๊ฐํ์ผ๋ ๋ด๋ถ ๊ธฐ๋ฅ ๋ณํ๋ฅผ ์์ธํ ์ดํด๋ณด๊ฒ ์ต๋๋ค. ์๋ก์ด ๊ธฐ๋ฅ๋ค Java 8 ์์ค ๋ ๋ฒจ์ ๋์์ผ๋ก ์ฑ๋ฅ๊ณผ ์ฝ๋ ๊ฐ์ Stream๋ฅผ ๋ฐํํ๋ Fetchable#stream() ์ถ๊ฐ try-with-resources..
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ์คํ๋ง ๋ฐ์ดํฐ์์ ์ ๊ณตํ๋ Querydsl ๊ธฐ๋ฅ์ ์๊ฐํฉ๋๋ค. Repository ์ธํฐํ์ด์ค ์ง์: QuerydslPredicateExecutor ๊ณต์ ๋ฌธ์ ์ฐธ์กฐ ์คํ๋ง ๋ฐ์ดํฐ๋ QuerydslPredicateExecutor๋ผ๋ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. public interface QuerydslPredicateExecutor { Optional findById(Predicate predicate); // (1) Iterable findAll(Predicate predicate); // (2) long count(Predicate predicate); // (3) boolean exists(Predicate predicate); // (4) // โฆ more funct..
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. SQL ํจ์๋ Dialect๋ก ๋ฑ๋กํ ์ธ์ด์ ๋ํด์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค. ํ์ฌ ํ๋ก์ ํธ์์๋ H2 ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ๋ฏ๋ก H2Dialect์ ๋ช ์๋ ํจ์๋ค๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค. H2Dialect.java /* * Hibernate, Relational Persistence for Idiomatic Java * * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or . */ package org.hibernate.dialect; import java.sql.SQLException; import java...
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ์ด์ ํฌ์คํ ์ ์ด์ด์ Querydsl์ ๊ธฐ๋ณธ ๋ฌธ๋ฒ์ ์๊ฐํฉ๋๋ค. ๊ธฐ๋ณธ Join ์ฒซ ๋ฒ ์งธ ํ๋ผ๋ฏธํฐ์ joinํ ๋์, ๋ ๋ฒ ์งธ ํ๋ผ๋ฏธํฐ์ ๋ณ์นญ์ผ๋ก ์ฌ์ฉํ Q Type์ ์ง์ ํฉ๋๋ค. package io.lcalmsky.querydsl.domain; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBoot..
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. ์ด์ ํฌ์คํ ์ ์ด์ด์ Querydsl์ ๊ธฐ๋ณธ ๋ฌธ๋ฒ์ ์๊ฐํฉ๋๋ค. ์ ๋ ฌ JPAQueryFactory์์ orderBy ๋ฉ์๋๋ฅผ ํธ์ถํด ์ ๋ ฌ ๊ธฐ๋ฅ์ ์ฌ์ฉํฉ๋๋ค. orderBy์ ํ๋ผ๋ฏธํฐ๋ก ์ ๋ ฌํ ํญ๋ชฉ๋ค์ ์ ๋ฌํ๋๋ฐ ์๋ ํ ์คํธ ์ฝ๋์ฒ๋ผ ์์ฑํ๋ฉด ๋ฉ๋๋ค. package io.lcalmsky.querydsl.domain; import com.querydsl.jpa.impl.JPAQueryFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.spring..
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. Querydsl์ ๊ธฐ๋ณธ ๋ฌธ๋ฒ์ ์๊ฐํฉ๋๋ค. Q Type ์ด์ ํฌ์คํ ์์ ์ฌ์ฉํ Entity๋ค์ compileQuerydsl์ ์ด์ฉํด ๋ชจ๋ Q Type์ผ๋ก ๋ณํํ์์ต๋๋ค. (์์ธํ ๋ด์ฉ์ ์ด์ ํฌ์คํ ์ฐธ๊ณ ) Q Type ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ด์ ํฌ์คํ ์์๋ ์๊ฐํ์ง๋ง ๋ ๊ฐ์ง๊ฐ ์์ต๋๋ค. QPlayer player = new QPlayer("p"); // (1) QPlayer player = Qplayer.player; // (2) (1) alias๋ฅผ ๋ณ๋๋ก ์ง์ ํ๊ณ new๋ฅผ ์ด์ฉํด ๊ฐ์ฒด๋ฅผ ์์ฑํฉ๋๋ค. (2) QPlayerํด๋์ค์ static์ผ๋ก ์ ์ธ๋ ๊ฐ์ฒด๋ฅผ ๊ฐ์ ธ์ ์ฌ์ฉํฉ๋๋ค. alias์ ๊ธฐ๋ณธ ๊ฐ์ Entity ์ด๋ฆ ์ ๋๋ค. (Player์ธ ๊ฒฝ์ฐ player) ๊ตณ์ด..
๋ชจ๋ ์์ค ์ฝ๋๋ ์ฌ๊ธฐ ์์ต๋๋ค. Querydsl์ ์ฌ์ฉํ๊ธฐ ์ํด ํ๋ก์ ํธ ์ค์ ๋ถํฐ ์ฐจ๊ทผ์ฐจ๊ทผ ๋ฌ๋ ค๋ด ์๋ค! ๋จผ์ ์๋ฐ ๋ฒ์ ์ 11, ์คํ๋ง ๋ฒ์ ์ 2.5.2๋ฅผ ์ ํํ์๊ณ gradle ํ๋ก์ ํธ๋ก ์์ฑํ์ฌ ์๋ ๋ค ๊ฐ์ง dependency๋ฅผ ์ค์ ํ์์ต๋๋ค. spring-boot-starter-web spring-boot-starter-data-jpa lombok h2 build.gradle ์์ ๊ฐ์ด ์ค์ ํ์ จ๋ค๋ฉด build.gradle ํ์ผ์ด ์๋ ์ฒ๋ผ ์์ฑ๋์์ํ ๋ฐ์, plugins { id 'org.springframework.boot' version '2.5.2' id 'io.spring.dependency-management' version '1.0.1..
- Total
- 83,835
- Today
- 55
- Yesterday
- 439
- @ManyToOne
- Spring Boot Tutorial
- leetcode
- leetcode bst
- spring boot application
- Spring Data JPA
- ์คํ๋ง ๋ถํธ ํํ ๋ฆฌ์ผ
- spring boot app
- Spring Boot JPA
- ์คํ๋ง ๋ถํธ
- ์คํ๋ง ๋ถํธ jwt
- leetcode stack
- JPA
- ์๊ณ ๋ฆฌ์ฆ
- spring boot jwt
- QueryDSL
- Jackson
- ์คํ๋ง ๋ฐ์ดํฐ jpa
- intellij
- Java
- r
- gRPC
- ์คํ๋ง ๋ถํธ ์ ํ๋ฆฌ์ผ์ด์
- ์คํ๋ง๋ถํธ
- ์คํ๋ง ๋ถํธ ํ์ ๊ฐ์
- proto3
- JSON
- leetcode binary search
- Linux
- Spring Boot