Home > Software engineering >  Not generating Q classes for parent in query sql
Not generating Q classes for parent in query sql

Time:10-03

I have an entity as shown below:

@Table(name = "applicableTax")
@Entity
public class ApplicableTax extends Auditor {

@Id
private Integer id;

}

Auditor is in a different package with content.

public class Auditor {

    @LastModifiedBy
    protected String modifiedBy;
    @LastModifiedDate
    private Date modifiedDate;

}

Now above code is generating QClasses for ApplicableTax.java but it is not generating QClasses for Auditor. Maven build is getting failed in QApplicableTax.java with cannot not find symbol QAuditor.

CodePudding user response:

Inheritance in JPA is not automatic. Means you have to declare the inheritance using @MappedSuperclass

@MappedSuperclass
public class Auditor {

    @LastModifiedBy
    protected String modifiedBy;
    @LastModifiedDate
    private Date modifiedDate;

}

CodePudding user response:

I have resolved this issue by explicitly disabling generation of parent class Qclasses by using @QueryExclude

http://querydsl.com/static/querydsl/3.5.0/apidocs/com/mysema/query/annotations/QueryExclude.html

Thanks @Simon for pointing out the issue.

  • Related