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
Jpa 在元模型中找不到键类[]的[EntityType]-请验证persistence.xml中引用了[Entity]类_Jpa_Eclipselink - Fatal编程技术网

Jpa 在元模型中找不到键类[]的[EntityType]-请验证persistence.xml中引用了[Entity]类

Jpa 在元模型中找不到键类[]的[EntityType]-请验证persistence.xml中引用了[Entity]类,jpa,eclipselink,Jpa,Eclipselink,DAO代码: @Entity @Table(name="temp_param") public class ParamConfiguration implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "param_group") private String paramGroup; public String getParamGroup() { retur

DAO代码:

@Entity
@Table(name="temp_param")
public class ParamConfiguration implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "param_group")
private String paramGroup;
public String getParamGroup() {
    return paramGroup;
}
public void setParamGroup(String paramGroup) {
    this.paramGroup = paramGroup;
}
CriteriaQuery cq=entityManager
.getCriteriaBuilder()
.createQuery(ParamConfiguration.class);
最终根ac=cq.from(ParamConfiguration.class);
cq.选择(ac);
TypedQuery tq=entityManager.createQuery(cq);
List AClist=tq.getResultList();
持久性xml:

 CriteriaQuery<ParamConfiguration> cq = entityManager
                .getCriteriaBuilder()
                .createQuery(ParamConfiguration.class);
     final Root<ParamConfiguration> ac = cq.from(ParamConfiguration.class);
     cq.select(ac);
     TypedQuery<ParamConfiguration> tq=entityManager.createQuery(cq);
     List<ParamConfiguration> AClist=tq.getResultList();

org.eclipse.persistence.jpa.PersistenceProvider
java:/comp/env/jdbc/CDM
net.odcorp.sas.mrm.beans.AffinityConfiguration
真的
有人能帮我吗。。。。是@entity类必须具有DB表中的所有列


仅供参考,我使用Teradata作为DB、Spring、JPA、JSF。

persistence.xml文件中没有列出您的
ParamConfiguration
实体,您可以将选项
排除未列出的类
设置为
true

将以下内容添加到persistence.xml文件:

    <persistence-unit name="serCoupons_Cdm" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <non-jta-data-source>java:/comp/env/jdbc/CDM</non-jta-data-source>


    <class>net.odcorp.sas.mrm.beans.AffinityConfiguration</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
net.odcorp.sas.mrm.beans.ParamConfiguration

确保软件包正常。

在persistence.xml文件中尝试此操作

<class>net.odcorp.sas.mrm.beans.ParamConfiguration</class>

我也有同样的问题,但在我的情况下,我错过了 @表注释。另外,在我的代码中,不要使用@Column注释,我使用@Id正下方的@GeneratedValue(strategy=GenerationType.IDENTITY)。它对我有效,而不使用

<class>com.package.Class</class>
true

我可以提供我的源代码,因为我刚刚用它来了解JPA。

我看不出您正在persistence.xml中映射实体类ParamConfiguration,但是您可以在实体中有一些字段,这些字段在数据库中没有等价的字段,但它们需要用@TransientOh注释,您的peristence文件必须是
persistence.xml
,而不是persistence.xml。我只有在运行
java-jar something.jar
时才会出现此错误。当我在cloudFoundry或mvn springboot运行中运行它时,它可以正常工作。将
排除未列出的类
设置为true将不会拾取所有带注释的实体类。它不工作。。。是否必须将表中的所有列添加到实体类
<persistence-unit name="serCoupons_Cdm" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>jdbc/CDM</non-jta-data-source>
<exclude-unlisted-classes>false<exclude-unlisted-classes/>
<class>com.package.Class</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>