Skip to content

Commit

Permalink
Merge: (#35) QueryDsl 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
alsdl0629 authored Nov 9, 2023
2 parents 630d451 + cdedda2 commit e4d26a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.kapt3.base.Kapt.kapt

plugins {
id("org.springframework.boot") version "3.1.4"
Expand All @@ -8,6 +9,7 @@ plugins {
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
kotlin("plugin.jpa") version "1.8.22"
kotlin("kapt") version "1.8.21"
}

group = "team.sfe"
Expand Down Expand Up @@ -53,6 +55,12 @@ dependencies {

// redis
implementation("org.springframework.boot:spring-boot-starter-data-redis")

// querydsl
implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
kapt("com.querydsl:querydsl-apt:5.0.0:jakarta")
kapt("jakarta.annotation:jakarta.annotation-api")
kapt("jakarta.persistence:jakarta.persistence-api")
}

allOpen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Element(
@Column(columnDefinition = "VARCHAR(20)")
val name: String,

@field:NotNull
@Column(columnDefinition = "VARCHAR(100)")
val content: String,

@field:NotNull
@Column(columnDefinition = "CHAR(10)")
val type: Type
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/team/sfe/server/global/config/QueryDslConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package team.sfe.server.global.config

import com.querydsl.jpa.impl.JPAQueryFactory
import jakarta.persistence.EntityManager
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class QueryDslConfig(
val entityManager: EntityManager
) {

@Bean
fun jpaQueryFactory() = JPAQueryFactory(entityManager)
}

0 comments on commit e4d26a2

Please sign in to comment.