org.hibernate.hql.internal.ast.QuerySyntaxException: MyEntity is not mapped in EAP 6
Issue
- When using an entity manager with a transaction type of
RESOURCE_LOCALto execute a query, the following exception is raised.
org.hibernate.hql.internal.ast.QuerySyntaxException: MyEntity is not mapped [from MyEntity me where me.aproperty = :aproperty]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
...
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) [hibernate-entitymanager-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
... 16 more
- The following code is used to create the entity manager given a persistence unit name and a data source name:
private static EntityManagerFactory buildEntityManagerFactory(String aInPersistenceUnit, String aInDataSource)
{
Map<String, String> lConfigOverrides = new HashMap<>();
lConfigOverrides.put("javax.persistence.transactionType", PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
if (aInDataSource != null)
{
lConfigOverrides.put("javax.persistence.nonJtaDataSource", aInDataSource);
lConfigOverrides.put("javax.persistence.jtaDataSource", aInDataSource);
}
return Persistence.createEntityManagerFactory(aInPersistenceUnit, lConfigOverrides);
}
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
