Generation of Query classes within a type hierarchy becomes inconsistent when using @Column annotation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Consider the following type hierarchy:
- A2 extends A
- B2 extends B
A has a reference to B, and for the more specific classes A2 has a reference to B2. See the example code below.
Now the problem is: as soon as we use the @Column annotation in A2, the generation of the Query classes becomes inconsistent, i.e. QA2.a2.b() is no longer of type B2 but of type B instead, which breaks the ability of formulating polymorphic queries in this case.
Test Case below (just uncomment the @Column annotation and you will get a compile error in main()):
<code>
package test;
import javax.persisten
public class Test {
public static void main(String[] args) {
QB2 qb2 = QA2.a2.b();
}
}
@Entity
class A {
B b;
A(B b) {
this.b = b;
}
B getB() {
return b;
}
}
@Entity
class A2 extends A {
// XXX: uncomment @Comment to break generation - QA2.a2.b() will then return B instead of B2
// @Column
int foo;
A2(B2 b2) {
super(b2);
}
@Override
B2 getB() {
return (B2) super.getB();
}
}
@Entity
class B {
}
@Entity
class B2 extends B {
}
</code>
This behaviour exists in 2.2.1 and 2.2.0.beta5. Is there a quick work-around?