Use a single persistence unit as both managed and unmanaged unit in JBoss EAP

Solution Verified - Updated -

Issue

  • A persistence unit "MyUnit" is declared in a persistence.xml within <EAR>/lib/psunit.jar
  • Entities within the unit jar are auto-discovered for managed (e.g. injected) entity managers
  • References (e.g. in queries) to the bundled entities fail when using un-managed entity managers

    org.hibernate.hql.internal.ast.QuerySyntaxException: Employee is not mapped [from Employee e]
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.