Question

i have this simple entity

@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;
}

now i try to create with the querydsl apt-maven-plugin to generate the Q* classes. in my pom.xml i have this configuration:

<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>

the problem now is that the last processor overwrite the first generated class with the new one. The idea was to have separate Q* clases for neo4j and for JPA because of the transient fields. The results with only one processor:

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);
    }

}

does anybody know how to separate these generated classes?

Was it helpful?

Solution

You will need to use two executions for this

<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>

The second execution uses N as the class name prefix instead of default Q. Feel free to shape this for your needs.

Reference http://www.querydsl.com/static/querydsl/3.3.2/reference/html/ch03s03.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top