Thiago Sayão
Thiago Sayão

Reputation: 2347

how to reference JPA annotated classes from jar dependency to generate QueryDsl Q classes?

I have the @Entity annotated classes on Project A. Project B has a dependency on Project A.

I want to generate QueryDsl Q classes on Project B, so Project A would not have a dependency on QueryDsl.

If i follow the standard instructions (as described in http://www.querydsl.com/static/querydsl/4.1.3/reference/html_single/) to enable QueryDsl with JPA on Project B, it does not detect the annotated classes on project B.

According to this Github issue (https://github.com/querydsl/querydsl/issues/196), this is not possible, unless using an annotation on the package level. It dates 2012, so it might be possible now. Is it?

Thanks.

Upvotes: 2

Views: 835

Answers (1)

Thiago Sayão
Thiago Sayão

Reputation: 2347

Just found the answer:

Add to the pom file:

  <plugin>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-maven-plugin</artifactId>
    <version>${querydsl.version}</version>
    <executions>
      <execution>
        <phase>process-classes</phase>
        <goals>
          <goal>jpa-export</goal>
        </goals>
        <configuration>
          <targetFolder>target/generated-sources/java</targetFolder>
          <packages>
            <package>package.containing.entities</package>
          </packages>
        </configuration>
      </execution>
    </executions>
  </plugin>

Upvotes: 2

Related Questions