2
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 class:

@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 code:

 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>

Can anyone help me on this.... Is the @entity class must have all the columns in the DB table.

FYI im using Teradata as DB, Spring, JPA, JSF.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Saa Satyam
  • 71
  • 1
  • 5
  • 1
    i don't see you are mapping your Entity class ParamConfiguration in persistence.xml, however you can have fields in your Entity which does not have equivalent in Database, but they need to be annotated with @Transient – drgPP Sep 02 '15 at 10:59
  • Oh, your peristence file must be `persistence.xml`, not persistance.xml – Buhake Sindi Sep 02 '15 at 11:05
  • I get this error only when I run `java -jar something.jar`. It works fine when I run it in cloudFoundry or `mvn springboot run`. – Santosh Hegde Jul 30 '20 at 10:57

3 Answers3

1

Your ParamConfiguration entity is not listed in the persistence.xml file and you set the option exclude-unlisted-classes to true

add this to your persistence.xml file :

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

be sure that the package is ok.

Jib'z
  • 953
  • 1
  • 12
  • 23
1

Try this in your persistence.xml file,

<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 has true as it's default value. or if its set to true, then you need to specify the tag manually to list the entity class,

<class>com.package.Class</class>
Lucky
  • 16,787
  • 19
  • 117
  • 151
0

I had the same issue, but in my case I was missing the @Table annotation. Also in my code don't use @Column annotation, I use @GeneratedValue(strategy= GenerationType.IDENTITY) right below @Id. It works for me without using

    <exclude-unlisted-classes>true</exclude-unlisted-classes>

I can provide my source code since I've just been using to learn about JPA.

carlos palma
  • 722
  • 3
  • 12
  • 29