Generic @MappedSuperclass with @Embedded => Compiler error in _super initialization for @Entity subclass #223

Closed
mkq opened this Issue Sep 3, 2012 · 6 comments

Comments

Projects
None yet
2 participants
@mkq

mkq commented Sep 3, 2012

For the following classes, Querydsl 2.7.0 shows a FilerException during generation. The generated class QFoo has a compiler error at the QBaseEntity constructor invocation.

@Embeddable 
public class Range<T extends Comparable<? super T>> { ... }

@MappedSuperclass 
public abstract class BaseEntity<T extends Comparable<? super T>> implements Serializable {
  @Embedded
  private Range<T> range;
  ...
}

@Entity
public class Foo extends BaseEntity<Integer> { ... }
@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 3, 2012

Member

Can you reproduce the issue with 2.7.2?

Member

timowest commented Sep 3, 2012

Can you reproduce the issue with 2.7.2?

@mkq

This comment has been minimized.

Show comment
Hide comment
@mkq

mkq Sep 3, 2012

The latest version I find is 2.7.0. Where can i get 2.7.2?

BTW, I was planning to attach the full source and Eclipse project, but can't find an attach feature. So here it goes:

src/test/querydsl/embed/Range.java

package test.querydsl.embed;

public class Range<T extends Comparable<? super T>>
{
    private T min;
    private T max;

    public T getMin() { return min; }

    public void setMin(T min) { this.min = min; }

    public T getMax() { return max; }

    public void setMax(T max) { this.max = max; }
}

src/test/querydsl/embed/BaseEntity.java

package test.querydsl.embed;

import java.io.Serializable;

import javax.persistence.Embedded;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class BaseEntity<T extends Comparable<? super T>> implements Serializable
{
    @Embedded
    private Range<T> range;

    public Range<T> getRange()
    {
        return range;
    }

    public void setRange(Range<T> range)
    {
        this.range = range;
    }
}

src/test/querydsl/embed/Foo.java

package test.querydsl.embed;

import javax.persistence.Entity;

@Entity
public class Foo extends BaseEntity<Integer>
{
}

generate.ant.xml (called with system property like querydsl.home=D:/java/querydsl-jpa-2.7.0)

<project name="querydsl-embed-test-generate-metamodel" default="clean+generate-entity-meta">
    <path id="classpath">
        <fileset dir="${querydsl.home}" includes="**/*.jar" />
    </path>

    <property name="src.generated" value="src-generated" />

    <target name="clean">
        <delete verbose="true" includeemptydirs="true">
            <fileset dir="${src.generated}" includes="**/*" defaultexcludes="false"/>
        </delete>
    </target>

    <target name="generate-entity-meta">
        <mkdir dir="${src.generated}"/>
        <javac classpathref="classpath" includeantruntime="no" failonerror="false" fork="true">
            <src><path path="src"/></src>
            <compilerarg value="-proc:only" />
            <compilerarg value="-Aeclipselink.persistencexml=${src}/META-INF/persistence.xml" />
            <compilerarg value="-s" />
            <compilerarg value="${src.generated}" />
        </javac>
    </target>

    <target name="clean+generate-entity-meta" depends="clean, generate-entity-meta" />
</project>

mkq commented Sep 3, 2012

The latest version I find is 2.7.0. Where can i get 2.7.2?

BTW, I was planning to attach the full source and Eclipse project, but can't find an attach feature. So here it goes:

src/test/querydsl/embed/Range.java

package test.querydsl.embed;

public class Range<T extends Comparable<? super T>>
{
    private T min;
    private T max;

    public T getMin() { return min; }

    public void setMin(T min) { this.min = min; }

    public T getMax() { return max; }

    public void setMax(T max) { this.max = max; }
}

src/test/querydsl/embed/BaseEntity.java

package test.querydsl.embed;

import java.io.Serializable;

import javax.persistence.Embedded;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class BaseEntity<T extends Comparable<? super T>> implements Serializable
{
    @Embedded
    private Range<T> range;

    public Range<T> getRange()
    {
        return range;
    }

    public void setRange(Range<T> range)
    {
        this.range = range;
    }
}

src/test/querydsl/embed/Foo.java

package test.querydsl.embed;

import javax.persistence.Entity;

@Entity
public class Foo extends BaseEntity<Integer>
{
}

generate.ant.xml (called with system property like querydsl.home=D:/java/querydsl-jpa-2.7.0)

<project name="querydsl-embed-test-generate-metamodel" default="clean+generate-entity-meta">
    <path id="classpath">
        <fileset dir="${querydsl.home}" includes="**/*.jar" />
    </path>

    <property name="src.generated" value="src-generated" />

    <target name="clean">
        <delete verbose="true" includeemptydirs="true">
            <fileset dir="${src.generated}" includes="**/*" defaultexcludes="false"/>
        </delete>
    </target>

    <target name="generate-entity-meta">
        <mkdir dir="${src.generated}"/>
        <javac classpathref="classpath" includeantruntime="no" failonerror="false" fork="true">
            <src><path path="src"/></src>
            <compilerarg value="-proc:only" />
            <compilerarg value="-Aeclipselink.persistencexml=${src}/META-INF/persistence.xml" />
            <compilerarg value="-s" />
            <compilerarg value="${src.generated}" />
        </javac>
    </target>

    <target name="clean+generate-entity-meta" depends="clean, generate-entity-meta" />
</project>
@mkq

This comment has been minimized.

Show comment
Hide comment
@mkq

mkq Sep 3, 2012

Never mind the question where to get 2.7.2. I found it in http://source.mysema.com/maven2/releases/com/mysema/querydsl/querydsl-core/2.7.2/ and will try.

mkq commented Sep 3, 2012

Never mind the question where to get 2.7.2. I found it in http://source.mysema.com/maven2/releases/com/mysema/querydsl/querydsl-core/2.7.2/ and will try.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 4, 2012

Member

I can confirm, that this fails also in 2.7.2. I will provide a fix ASAP.

Member

timowest commented Sep 4, 2012

I can confirm, that this fails also in 2.7.2. I will provide a fix ASAP.

@mkq

This comment has been minimized.

Show comment
Hide comment
@mkq

mkq Sep 4, 2012

Thanks. As a maven noob, i was still struggling to get all needed jars for 2.7.2.

mkq commented Sep 4, 2012

Thanks. As a maven noob, i was still struggling to get all needed jars for 2.7.2.

timowest added a commit that referenced this issue Sep 4, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 10, 2012

Member

Released in 2.7.3

Member

timowest commented Sep 10, 2012

Released in 2.7.3

@timowest timowest closed this Sep 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment