简体   繁体   中英

Create (querydsl) metamodel for Entity from jar

I'm having problems generating the querydsl metamodel (ie the Q-classes) for an Entity comming from a jar included in the dependencies for my project.

The class (BaseEntity) is an abstract baseclass for most of my entities (annotated with @MappedSuperclass) and for project reasons and dependencies to other projects this baseclass has to be in a separate jar.

When I now include this jar as a dependency for the project which contains my non-abstract entities and try to generate the metamodel (using the com.mysema.maven:apt-maven-plugin) it doesn't recognize the BaseEntity and complains with "Cannot find symbol" QBaseEntity.

I kindof solved this by making maven unpack the source file (ie BaseEntity.java) into an additional source folder of the dependent project but this is kind of ugly as I have to always remember to change the version number in case of releases and also have the source dependency in my pom and it's also not very intuitive.

So my question(s) is/are:

  1. Can I make querydsl generate the metamodel for the class from the jar somehow without copying the source to the dependent project?
  2. If this is not possible: can I make querydsl metamodel generation operate on the .class file rather than on the .java source file (with that I wouldn't need the source dependency and could only extract the .class file from the existing dependency)

Any help is greatly appreciated, thanks

You can use the QueryEntities annotation to refer to BaseEntity from the main source project. A package level annotation is advisable.

You should add - info.java file in your package

@QueryEntities(value = {BaseEntity.class})
package xxxx.xxxx.xxx;

import com.querydsl.core.annotations.QueryEntities;
import xxx.xxxx.BaseEntity;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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