Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPA:如何选择@Embeddeble类_Java_Jpa_Ejb 3.0 - Fatal编程技术网

Java JPA:如何选择@Embeddeble类

Java JPA:如何选择@Embeddeble类,java,jpa,ejb-3.0,Java,Jpa,Ejb 3.0,我将从@Embeddeble Class Certification中选择所有列。但我不能选择它。如何选择可嵌入类 @Entity public class Department implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; priv

我将从@Embeddeble Class Certification中选择所有列。但我不能选择它。如何选择可嵌入类

@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;
  }

  .....
如果运行ResultService,会出现以下异常:

原因:java.lang.IllegalArgumentException:在EntityManager中创建查询时发生异常: 异常说明:编译查询时出错[从证书c中选择c]。未知的实体类型[证书]


如何选择@Embeddeble类?

您需要通过真实实体类,即
部门
检索
认证
。一个查询示例如下:

   select cer from Department dep join dep.certifications cer
或者,您可能希望检索符合条件的部门实体,然后使用它们获取证书

   select cer from Department dep join dep.certifications cer