Search code examples
javaspringspring-bootspring-data-jpaquerydsl

How to generate Query classes when an entity extends a class from an external package that does not have support for QueryDsl?


I am having an entity class like below:

public class Apple extends ExternalClass implements Serializable {}

Here Apple is extending a class ExternalClass which is a part of a external package(not part of project source code).

When I am trying to use mvn compile, the compilation is failing with an error

error: cannot find symbol
symbol: class QExternalClass
location: package com.example.models
public final com.example.models.ExternalClass _super = new com.example.models.ExternalClass(this);

One solution that I can think of is to add QueryDsl to the external package, and then importing it. Is there any other solution available for this problem.


Solution

  • One solution is by adding @QueryEntities(value = {ExternalClass.class}) to package-info.

    For more details check How to generate query-dsl Q classes on external entity?