Making IntelliJ understand your QueryDSL generated classes needs some work. QueryDSL has an annotation processor to generate Q-classes from your entities. Just running the annotation processor doesn’t mean your IDE will understand where to find the generated classes. I was struggling to get IntelliJ IDEA picking up the generated classes. Probably there are more ways to get this done in Gradle, but I found out one that’s pretty easy to configure, without any adjustments to you IntelliJ settings. Because you could configure the annotation processor via the IntelliJ settings in the Annotation Processor screen (Build, Execution, Deployment → Compiler → Annotation Processors). It would be easier if you can achieve the same just using Gradle. With the following in your Gradle build file, it generates the classes and instructs IntelliJ where to find the classes:

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath('net.ltgt.gradle:gradle-apt-plugin:0.18')
    }
}

apply plugin: 'net.ltgt.apt'
apply plugin: 'net.ltgt.apt-idea'

def queryDslVersion = '4.1.3'

dependencies {
    compile("com.querydsl:querydsl-core:${queryDslVersion}")
    compile("com.querydsl:querydsl-jpa:${queryDslVersion}")
}

dependencies {
    compile "com.querydsl:querydsl-jpa:${queryDslVersion}"
    annotationProcessor (
        "com.querydsl:querydsl-apt:${queryDslVersion}:jpa",
        "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final",
        "javax.annotation:javax.annotation-api:1.3.2",
    )
}

If you’re using Lombok in your entities, generating the QueryDSL classes will fail, as it won’t understand the Lombok annotations. To solve this you have to add the Lombok dependency to the annotationProcessor block.

dependencies {
    compile "com.querydsl:querydsl-jpa:${queryDslVersion}"
    compileOnly 'org.projectlombok:lombok:1.16.18'
    annotationProcessor(
        "com.querydsl:querydsl-apt:${queryDslVersion}:jpa",
        "org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final",
        "javax.annotation:javax.annotation-api:1.3.2",
        "org.projectlombok:lombok"
    )
}
shadow-left