假设我有这些calsses:
public class A {
public Long id;
public B b;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setB(B b) {
this.b = b;
}
public B getB() {
return b;
}
}
public class B {
public Long id;
public String code;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setCode(String code) {
this.code = code;
}
public Long getCode() {
return code;
}
public B(Long id) {
this.id = id;
}
}
我想执行此查询:
select new B(a.b.id) as b, a.b.code as bCode
from A a
但是不起作用。
答案 0 :(得分:0)
试试这个
select new B(b1.id) as b, b1.code as bCode
from A a
inner join a.b as b1