javajpaquerydsl

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?

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.


Solution

  • JB Nizets comment is the answer:

    No the query needs to be translated to SQL, and executed by the database. 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