0

我将从@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 类认证

@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]。未知的实体类型 [Certification]。

我如何选择@Embeddable 类?

4

1 回答 1

0

您需要Certification通过真实的实体类(即Department. 一个示例查询可能如下:

   select cer from Department dep join dep.certifications cer

或者,您可能希望检索符合条件的部门实体,然后使用它们获取认证。

于 2013-05-21T15:28:34.743 回答