Skip to content

Commit

Permalink
✨ Practice(#6) : QueryDSL 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Jangwon0319 committed Nov 6, 2024
1 parent eff06d3 commit 42e7baf
Show file tree
Hide file tree
Showing 23 changed files with 1,015 additions and 11 deletions.
72 changes: 61 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}

group = 'umc'
Expand All @@ -13,26 +14,75 @@ java {
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.hibernate.orm:hibernate-core:6.0.2.Final'
implementation 'mysql:mysql-connector-java:8.0.33'

// 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"

// Jackson (버전 지정 제거)
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.core:jackson-annotations'
implementation 'com.fasterxml.jackson.core:jackson-core'

// Lombok
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'

// 추가된 의존성
implementation 'org.hibernate.validator:hibernate-validator:8.0.0.Final' // Bean Validation
implementation 'org.glassfish:jakarta.el:4.0.2' // Expression Language (EL)

// ANTLR 의존성 추가
implementation 'org.antlr:antlr4-runtime:4.10'

// SpringDoc OpenAPI
implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'
implementation 'org.springdoc:springdoc-openapi-data-rest:1.6.9'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/main/resources']
}
}
}

tasks.named('test') {
useJUnitPlatform()
}

// Querydsl 설정부
def generated = 'src/main/generated'

querydsl {
jpa = true
querydslSourcesDir = generated
}
sourceSets {
main.java.srcDir generated
}

compileQuerydsl{
options.annotationProcessorPath = configurations.querydsl
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
querydsl.extendsFrom compileClasspath
}
64 changes: 64 additions & 0 deletions src/main/generated/umc/spring/domain/QComment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package umc.spring.domain;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QComment is a Querydsl query type for Comment
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QComment extends EntityPathBase<Comment> {

private static final long serialVersionUID = -572500941L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QComment comment = new QComment("comment");

public final umc.spring.domain.common.QBaseEntity _super = new umc.spring.domain.common.QBaseEntity(this);

public final StringPath content = createString("content");

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final NumberPath<Long> id = createNumber("id", Long.class);

public final QMember member;

public final QReview review;

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public QComment(String variable) {
this(Comment.class, forVariable(variable), INITS);
}

public QComment(Path<? extends Comment> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}

public QComment(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}

public QComment(PathMetadata metadata, PathInits inits) {
this(Comment.class, metadata, inits);
}

public QComment(Class<? extends Comment> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.member = inits.isInitialized("member") ? new QMember(forProperty("member")) : null;
this.review = inits.isInitialized("review") ? new QReview(forProperty("review"), inits.get("review")) : null;
}

}

47 changes: 47 additions & 0 deletions src/main/generated/umc/spring/domain/QFoodCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package umc.spring.domain;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;


/**
* QFoodCategory is a Querydsl query type for FoodCategory
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QFoodCategory extends EntityPathBase<FoodCategory> {

private static final long serialVersionUID = -811463128L;

public static final QFoodCategory foodCategory = new QFoodCategory("foodCategory");

public final umc.spring.domain.common.QBaseEntity _super = new umc.spring.domain.common.QBaseEntity(this);

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final NumberPath<Long> id = createNumber("id", Long.class);

public final StringPath name = createString("name");

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public QFoodCategory(String variable) {
super(FoodCategory.class, forVariable(variable));
}

public QFoodCategory(Path<? extends FoodCategory> path) {
super(path.getType(), path.getMetadata());
}

public QFoodCategory(PathMetadata metadata) {
super(FoodCategory.class, metadata);
}

}

74 changes: 74 additions & 0 deletions src/main/generated/umc/spring/domain/QMember.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package umc.spring.domain;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QMember is a Querydsl query type for Member
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QMember extends EntityPathBase<Member> {

private static final long serialVersionUID = 1366956614L;

public static final QMember member = new QMember("member1");

public final umc.spring.domain.common.QBaseEntity _super = new umc.spring.domain.common.QBaseEntity(this);

public final StringPath address = createString("address");

public final ListPath<Comment, QComment> commentList = this.<Comment, QComment>createList("commentList", Comment.class, QComment.class, PathInits.DIRECT2);

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final StringPath email = createString("email");

public final EnumPath<umc.spring.domain.enums.Gender> gender = createEnum("gender", umc.spring.domain.enums.Gender.class);

public final NumberPath<Long> id = createNumber("id", Long.class);

public final DatePath<java.time.LocalDate> inactiveDate = createDate("inactiveDate", java.time.LocalDate.class);

public final ListPath<umc.spring.domain.mapping.MemberAgree, umc.spring.domain.mapping.QMemberAgree> memberAgreeList = this.<umc.spring.domain.mapping.MemberAgree, umc.spring.domain.mapping.QMemberAgree>createList("memberAgreeList", umc.spring.domain.mapping.MemberAgree.class, umc.spring.domain.mapping.QMemberAgree.class, PathInits.DIRECT2);

public final ListPath<umc.spring.domain.mapping.MemberMission, umc.spring.domain.mapping.QMemberMission> memberMissionList = this.<umc.spring.domain.mapping.MemberMission, umc.spring.domain.mapping.QMemberMission>createList("memberMissionList", umc.spring.domain.mapping.MemberMission.class, umc.spring.domain.mapping.QMemberMission.class, PathInits.DIRECT2);

public final ListPath<umc.spring.domain.mapping.MemberPrefer, umc.spring.domain.mapping.QMemberPrefer> memberPreferList = this.<umc.spring.domain.mapping.MemberPrefer, umc.spring.domain.mapping.QMemberPrefer>createList("memberPreferList", umc.spring.domain.mapping.MemberPrefer.class, umc.spring.domain.mapping.QMemberPrefer.class, PathInits.DIRECT2);

public final StringPath name = createString("name");

public final NumberPath<Integer> point = createNumber("point", Integer.class);

public final ListPath<Review, QReview> reviewList = this.<Review, QReview>createList("reviewList", Review.class, QReview.class, PathInits.DIRECT2);

public final EnumPath<umc.spring.domain.enums.SocialType> socialType = createEnum("socialType", umc.spring.domain.enums.SocialType.class);

public final StringPath specAddress = createString("specAddress");

public final EnumPath<umc.spring.domain.enums.MemberStatus> status = createEnum("status", umc.spring.domain.enums.MemberStatus.class);

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public QMember(String variable) {
super(Member.class, forVariable(variable));
}

public QMember(Path<? extends Member> path) {
super(path.getType(), path.getMetadata());
}

public QMember(PathMetadata metadata) {
super(Member.class, metadata);
}

}

67 changes: 67 additions & 0 deletions src/main/generated/umc/spring/domain/QMission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package umc.spring.domain;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QMission is a Querydsl query type for Mission
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QMission extends EntityPathBase<Mission> {

private static final long serialVersionUID = -453449888L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QMission mission = new QMission("mission");

public final umc.spring.domain.common.QBaseEntity _super = new umc.spring.domain.common.QBaseEntity(this);

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final DatePath<java.time.LocalDate> deadline = createDate("deadline", java.time.LocalDate.class);

public final NumberPath<Long> id = createNumber("id", Long.class);

public final ListPath<umc.spring.domain.mapping.MemberMission, umc.spring.domain.mapping.QMemberMission> memberMissionList = this.<umc.spring.domain.mapping.MemberMission, umc.spring.domain.mapping.QMemberMission>createList("memberMissionList", umc.spring.domain.mapping.MemberMission.class, umc.spring.domain.mapping.QMemberMission.class, PathInits.DIRECT2);

public final StringPath missionSpec = createString("missionSpec");

public final NumberPath<Integer> reward = createNumber("reward", Integer.class);

public final QStore store;

//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public QMission(String variable) {
this(Mission.class, forVariable(variable), INITS);
}

public QMission(Path<? extends Mission> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}

public QMission(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}

public QMission(PathMetadata metadata, PathInits inits) {
this(Mission.class, metadata, inits);
}

public QMission(Class<? extends Mission> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.store = inits.isInitialized("store") ? new QStore(forProperty("store"), inits.get("store")) : null;
}

}

Loading

0 comments on commit 42e7baf

Please sign in to comment.