File tree Expand file tree Collapse file tree 6 files changed +92
-3
lines changed
src/main/java/com/somemore Expand file tree Collapse file tree 6 files changed +92
-3
lines changed Original file line number Diff line number Diff line change 3636# ## VS Code ###
3737.vscode /
3838
39+ # ## resources
40+ /src /main /generated /
3941
4042# ## env file ###
41- * .env
43+ * .env
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ dependencies {
3737 runtimeOnly ' com.h2database:h2'
3838 runtimeOnly ' com.mysql:mysql-connector-j'
3939
40+ // Querydsl
41+ implementation ' com.querydsl:querydsl-jpa:5.0.0:jakarta'
42+ annotationProcessor " com.querydsl:querydsl-apt:${ dependencyManagement.importedProperties['querydsl.version']} :jakarta"
43+ annotationProcessor " jakarta.annotation:jakarta.annotation-api"
44+ annotationProcessor " jakarta.persistence:jakarta.persistence-api"
45+
4046 // OAuth & Security
4147 implementation ' org.springframework.boot:spring-boot-starter-oauth2-authorization-server'
4248 implementation ' org.springframework.boot:spring-boot-starter-oauth2-client'
@@ -58,6 +64,24 @@ dependencies {
5864 testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
5965}
6066
67+ // Querydsl 설정
68+ def generated = ' src/main/generated'
69+
70+ // QClass 파일 생성 위치를 지정
71+ tasks. withType(JavaCompile ). configureEach {
72+ options. getGeneratedSourceOutputDirectory(). set(file(generated))
73+ }
74+
75+ // java source set 에 querydsl QClass 위치 추가
76+ sourceSets {
77+ main. java. srcDirs + = [ generated ]
78+ }
79+
80+ // gradle clean 시에 QClass 디렉토리 삭제
81+ clean {
82+ delete file(generated)
83+ }
84+
6185tasks. named(' test' ) {
6286 useJUnitPlatform()
6387 jvmArgs(" -XX:+EnableDynamicAgentLoading" )
Original file line number Diff line number Diff line change 1+ package com .somemore .global .configure ;
2+
3+ import com .querydsl .jpa .impl .JPAQueryFactory ;
4+ import jakarta .persistence .EntityManager ;
5+ import jakarta .persistence .PersistenceContext ;
6+ import org .springframework .context .annotation .Bean ;
7+ import org .springframework .context .annotation .Configuration ;
8+
9+ @ Configuration
10+ public class QueryDslConfig {
11+
12+ @ PersistenceContext
13+ private EntityManager em ;
14+
15+ @ Bean
16+ public JPAQueryFactory jpaQueryFactory () {
17+ return new JPAQueryFactory (em );
18+ }
19+
20+ }
Original file line number Diff line number Diff line change 1+ package com .somemore .location .repository ;
2+
3+ import com .somemore .location .domain .Location ;
4+ import org .springframework .data .jpa .repository .JpaRepository ;
5+
6+ public interface LocationJpaRepository extends JpaRepository <Location , Long > {
7+
8+ }
Original file line number Diff line number Diff line change 11package com .somemore .location .repository ;
22
33import com .somemore .location .domain .Location ;
4- import org . springframework . data . jpa . repository . JpaRepository ;
4+ import java . util . Optional ;
55
6- public interface LocationRepository extends JpaRepository < Location , Long > {
6+ public interface LocationRepository {
77
8+ Location save (Location location );
9+
10+ Optional <Location > findById (Long id );
11+
12+ void deleteAllInBatch ();
813}
Original file line number Diff line number Diff line change 1+ package com .somemore .location .repository ;
2+
3+ import com .querydsl .jpa .impl .JPAQueryFactory ;
4+ import com .somemore .location .domain .Location ;
5+ import java .util .Optional ;
6+ import lombok .RequiredArgsConstructor ;
7+ import org .springframework .stereotype .Repository ;
8+
9+ @ RequiredArgsConstructor
10+ @ Repository
11+ public class LocationRepositoryImpl implements LocationRepository {
12+
13+ private final LocationJpaRepository locationJpaRepository ;
14+ private final JPAQueryFactory queryFactory ;
15+
16+ @ Override
17+ public Location save (Location location ) {
18+ return locationJpaRepository .save (location );
19+ }
20+
21+ @ Override
22+ public Optional <Location > findById (Long id ) {
23+ return locationJpaRepository .findById (id );
24+ }
25+
26+ @ Override
27+ public void deleteAllInBatch () {
28+ locationJpaRepository .deleteAllInBatch ();
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments