Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » No [EntityType] was found for the key class in the Metamodel(EclipseLink 2.7.4 using Criteria API)
No [EntityType] was found for the key class in the Metamodel [message #1808133] Tue, 18 June 2019 04:53
Hui Jessie is currently offline Hui JessieFriend
Messages: 2
Registered: June 2019
Junior Member
Hi all,

When I upgrade EclipseLink from 2.5.2 to 2.7.4, I met the exception when using Criteria API to select data.

12:09:17,383 ERROR [stderr] (default task-47) Caused by: java.lang.IllegalArgumentException: No [EntityType] was found for the key class [hk.judiciary.icms.model.dao.entity.HrnRsltCd] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>hk.judiciary.icms.model.dao.entity.HrnRsltCd</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.

12:09:17,404 ERROR [stderr] (default task-47) at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:180)

12:09:17,404 ERROR [stderr] (default task-47) at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:202)

12:09:17,404 ERROR [stderr] (default task-47) at org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl.internalFrom(CommonAbstractCriteriaImpl.java:119)

12:09:17,405 ERROR [stderr] (default task-47) at org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl.from(AbstractQueryImpl.java:275)


Here attach the Critieria API program:
    	CriteriaBuilder builder = getEntityManager().getEntityManagerFactory()
				.getCriteriaBuilder();
		CriteriaQuery<HrnRsltCd> criteria = builder.createQuery(HrnRsltCd.class);
		Root<HrnRsltCd> root = criteria.from(HrnRsltCd.class);
		criteria = criteria.select(root);
    	
		List<Predicate> andPredicates = new ArrayList<Predicate>();
		
		// Active Flag
		andPredicates.add(builder.equal(root.get(PARAM_ACTIVE_FLAG), "1"));

		if (!CommonUtil.isNullOrEmpty(andPredicates)) {
			criteria.where(andPredicates.toArray(new Predicate[0]));
		}

		TypedQuery<HrnRsltCd> query = getEntityManager().createQuery(criteria);
		return this.getResultList(query);



And here attach the persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence
    xmlns="java.sun.com/xml/ns/persistence"
    xmlns:xsi="xxx"
    xsi:schemaLocation="java.sun.com/xml/ns/persistence
                        java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">


    <persistence-unit name="icmshrnmcPU" transaction-type="JTA">
        
		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>java:jboss/datasources/appds</jta-data-source>  
        <jar-file>icms-entity-lib-0.2.9.544.jar</jar-file>
		<jar-file>../icmshrnmc-ejb.jar</jar-file>
		<properties>
			<property name="jboss.entity.manager.jndi.name" value="java:jboss/persistence/icmshrnmcPU" />
			<property name="eclipselink.target-database"
				value="org.eclipse.persistence.platform.database.oracle.Oracle11Platform" />
			<property name="eclipselink.target-server" value="JBoss" />
			<property name="eclipselink.composite-unit" value="true" />
			<property name="eclipselink.session.customizer"
				value="hk.judiciary.fmk.ejb.dao.entity.DefaultEntityInterceptor" />
			<property name="eclipselink.deploy-on-startup" value="true"/>
		</properties>  
		  
	</persistence-unit>    

</persistence>



The 2 jar file (icms-entity-lib-0.2.9.544.jar and icmshrnmc-ejb.jar) also have their persistence.xml, anyway, with different persistence-unit names.

I did not have such problem when using EclipseLink 2.5.2 . Please help!

Previous Topic:createQuery method hangs for a query with multiple clauses
Next Topic:When Oracle converts empty string to null, does EclipseLink cache reflect that?
Goto Forum:
  


Current Time: Fri Nov 01 00:14:43 GMT 2024

Powered by FUDForum. Page generated in 0.02949 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top