java.lang.IllegalArgumentException: No [EntityType] was found for the key class [] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class> </class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:173)
实体类:
@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;
}
DAO代码:
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();
persistance 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>
任何人都可以帮我这个....是@entity类必须拥有数据库表中的所有列。
仅供参考我使用Teradata作为DB,Spring,JPA,JSF。
答案 0 :(得分:1)
您的ParamConfiguration
实体未列在persistence.xml文件中,您将选项exclude-unlisted-classes
设置为true
将其添加到persistence.xml文件中:
<class>net.odcorp.sas.mrm.beans.ParamConfiguration</class>
确保包装正常。
答案 1 :(得分:1)
在persistence.xml文件中尝试此操作
<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/>
exclude-unlisted-classes
的默认值为true。或者如果设置为true,则需要手动指定标记以列出实体类
<class>com.package.Class</class>
答案 2 :(得分:0)
我有同样的问题,但就我而言,我错过了 @Table注释。另外在我的代码中没有使用@Column注释,我在@Id下面使用@GeneratedValue(strategy = GenerationType.IDENTITY)。它适用于我而不使用
<exclude-unlisted-classes>true</exclude-unlisted-classes>
我可以提供我的源代码,因为我刚刚用它来了解JPA。