2014-04-16 69 views
1

我有這個簡單的實體querydsl Q *類生成與Neo4j的部分= TRUE和JPA短暫

@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的插件創建生成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

這兩個處理器生成的代碼似乎是相同的。我想念什麼?如果它是一樣的,你爲什麼需要分開包裝? – fellahst

回答

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