Basics of QueryDSL 1

Sungju Kim·2024년 10월 9일

Sparta_Coding_Camp_TIL

목록 보기
46/53

Initial Settings

Add dependencies in build.gradle

dependencies {
    // querydsl
    implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
    annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
    annotationProcessor "jakarta.annotation:jakarta.annotation-api"
    annotationProcessor "jakarta.persistence:jakarta.persistence-api"
}

Then create a QueryDsl configuration file.

@Configuration
class QueryDslConfig {

    @PersistenceContext
    private EntityManager em;

    @Bean
    public JPAQueryFactory jpaQueryFactory() {
        return new JPAQueryFactory(JPQLTemplates.DEFAULT, em);
    }
}

Finally, run build under build in gradle.

After that you should be able to QCalss entities established under the build directory.

profile
Fully ✨committed✨ developer, always eager to learn!

0개의 댓글