简体   繁体   English

QueryDSL在生成的类中可以使用抽象类方法吗?

[英]QueryDSL It's possible usage of abstract Class methods in generated classes?

It's possible to use queryDSL generated classes to refer abstract methods from class? 可以使用queryDSL生成的类从类中引用抽象方法吗?

Here is a example: 这是一个例子:

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
class A {
    @Id private Long id;

    public getId/setId;
    protected abstract Date finalDate();
}

@Entity
class B extends A {
    private Date finalDate;

    public getFinalDate/setFinalDate;
}

@Entity
class C extends A {
    private B b;

    public getFinalDate(){return b.getFinalDate());
}

I would like to use a query like this: 我想使用这样的查询:

new JPAQuery<A>(em)
.select(a)
.where(a.finalDate.isNotNull())
.fetch();

But after build phase (Construct meta classes), the generated A class (QA.class), doesn't has nothing like. 但是在构建阶段(构造元类)之后,生成的A类(QA.class)就没有类似的东西。

JB Nizets comment is the answer: 答案是JB Nizets:

No the query needs to be translated to SQL, and executed by the database. 不需要将查询转换为SQL并由数据库执行。 The database doesn't know and care about your classes and methods. 数据库不知道也不关心您的类和方法。 All it knows about is its tables and columns. 它只知道其表和列。 – JB Nizet 10 hours ago – JB Nizet 10小时前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM