无法获取所有QClass列

找不到从生成的QClass中获取所有列的方法。

如何在select方法中定义所有foo列(实际上有很多)?

build.gradle:

...

ext {
    queryDslVersion = '4.2.2'
    javaxAnnotationVersion = '1.3.2'
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-webflux')

    compile "com.querydsl:querydsl-sql:${queryDslVersion}"

    compileonly('org.projectlombok:lombok')

    annotationProcessor('org.projectlombok:lombok')
    annotationProcessor("com.querydsl:querydsl-apt:${queryDslVersion}:general")
    annotationProcessor("javax.annotation:javax.annotation-api:${javaxAnnotationVersion}")

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage',module: 'junit-vintage-engine'
    }
    testImplementation('io.projectreactor:reactor-test')
}

idea {
    module {
        sourceDirs += file('generated/')
        generatedSourceDirs += file('generated/')
    }
}

尝试撰写查询:

var query = new SQLQuery<>(PostgreSQLTemplates.builder().printSchema().build());
query.select(foo) // foo has no all() or list() methods,nothing found that might be related to listing allcolumns
     .from(foo)
     ...

Foo实体:

@Data
@Table
@QueryEntity
public class Foo {

    @Id
    private UUID       id;
    private String  name;

    ...

}

生成的QFoo:

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

    private static final long serialVersionUID = -657824049L;

    public static final QFoo foo = new QFoo("foo");

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

    public final ComparablePath<java.util.UUID> id = createComparable("id",java.util.UUID.class);

    ...

    public QFoo(String variable) {
        super(Foo.class,forVariable(variable));
    }

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

    public QFoo(PathMetadata metadata) {
        super(Foo.class,metadata);
    }

}
show1234ab 回答:无法获取所有QClass列

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2690702.html

大家都在问