我将从@Embeddable Class Certification中选择所有列。但我不能选择它。我该怎么做才能选择Embeddable类。
@Entity
public class Department implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@ElementCollection
@CollectionTable(name = "Certification", joinColumns = {@JoinColumn(name="user_id")})
private List<Certification> certifications = new ArrayList<Certification>();
public List<Certification> getCertifications() {
return certifications;
}
public void setCertifications(List<Certification> certifications) {
this.certifications = certifications;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
.....
@Embeddable Class Certification
@Embeddable
public class Certification{
private String name;
private String certArt;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCertArt() {
return certArt;
}
public void setCertArt(String certArt) {
this.certArt = certArt;
}
......
如果我运行ResultService,我会得到以下异常:
引起:java.lang.IllegalArgumentException:在EntityManager中创建查询时发生异常: 例外描述:编译查询时出错[从认证c中选择c]。未知的实体类型[认证]。
如何选择@Embeddable类?
答案 0 :(得分:0)
您需要通过真实实体类(Certification
)检索Department
。一个示例查询可以如下:
select cer from Department dep join dep.certifications cer
或者,您可能想要检索符合条件的部门实体,然后使用它们获取认证。