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 を選択]。不明なエンティティ タイプ [証明書]。

@Embeddable クラスを選択するにはどうすればよいですか?

4

1 に答える 1

0

Certification実際の Entity クラス、つまり を介して取得する必要がありますDepartment。クエリの例は次のとおりです。

   select cer from Department dep join dep.certifications cer

または、適格な Department エンティティを取得し、それらを使用して証明書をフェッチすることもできます。

于 2013-05-21T15:28:34.743 に答える