我有这个简单的实体
@Entity(name = "person")
@NodeEntity(partial = true)
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Transient
@GraphProperty
private String sureName;
@QueryTransient
@Column(name = "surename")
private String firstName;
}
现在我尝试使用querydsl apt-maven-plugin创建生成Q *类。 在我的pom.xml中我有这个配置:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processors>
<processor>org.springframework.data.neo4j.querydsl.SDNAnnotationProcessor</processor>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
现在的问题是最后一个处理器用新的处理器覆盖第一个生成的类。由于瞬态场,我们的想法是为neo4j和JPA分别设置Q *。 只有一个处理器的结果:
SDNAnnotationProcessor
/**
* QPerson is a Querydsl query type for Person
*/
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QPerson extends EntityPathBase<Person> {
private static final long serialVersionUID = 1610526870L;
public static final QPerson person = new QPerson("person");
public final NumberPath<Long> id = createNumber("id", Long.class);
public final StringPath sureName = createString("sureName");
public QPerson(String variable) {
super(Person.class, forVariable(variable));
}
public QPerson(Path<? extends Person> path) {
super(path.getType(), path.getMetadata());
}
public QPerson(PathMetadata<?> metadata) {
super(Person.class, metadata);
}
}
JPAAnnotationProcessor
/**
* QPerson is a Querydsl query type for Person
*/
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QPerson extends EntityPathBase<Person> {
private static final long serialVersionUID = 1610526870L;
public static final QPerson person = new QPerson("person");
public final StringPath firstName = createString("firstName");
public final NumberPath<Long> id = createNumber("id", Long.class);
public QPerson(String variable) {
super(Person.class, forVariable(variable));
}
public QPerson(Path<? extends Person> path) {
super(path.getType(), path.getMetadata());
}
public QPerson(PathMetadata<?> metadata) {
super(Person.class, metadata);
}
}
有人知道如何分离这些生成的类吗?
答案 0 :(得分:2)
您需要为此
使用两次执行<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/jpa</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/neo4j</outputDirectory> <processor>org.springframework.data.neo4j.querydsl.SDNAnnotationProcessor</processor>
<options>
<querydsl.prefix>N</querydsl.prefix>
</options>
</configuration>
</execution>
</executions>
</plugin>
第二次执行使用N作为类名前缀而不是默认Q.可以根据需要随意设置它。
参考http://www.querydsl.com/static/querydsl/3.3.2/reference/html/ch03s03.html