Specified orm.xml at mapping-file in persistence.xml, does not used by hibernate's named query

Solution Verified - Updated -

Issue

Although user specifies orm.xml at in persistence.xml, hibernate does not find the named query in the orm.xml and throw exception.

stacktarace

java.lang.IllegalArgumentException: No query defined for that name [Before.select]
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.buildQueryFromName(AbstractEntityManagerImpl.java:753) ~[?:?]
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:730) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
    at org.apache.aries.jpa.support.osgi.impl.EmProxy.invoke(EmProxy.java:43) ~[?:?]
    at com.sun.proxy.$Proxy109.createNamedQuery(Unknown Source) ~[?:?]
    at Proxy02e73145_c9bf_4c24_bb57_64d0b1a07522.createNamedQuery(Unknown Source) ~[?:?]
        ~~ skip ~~

part of persistence.xml

<exclude-unlisted-classes>true</exclude-unlisted-classes>
<mapping-file>./sql/orm.xml</mapping-file>

sample-1.0.0-SNAPSHOT.jar

meta-inf/manifest.mf
meta-inf/
META-INF/maven/
META-INF/maven/sample/
META-INF/maven/sample/pom.properties
META-INF/maven/sample/pom.xml
META-INF/persistence.xml
osgi-inf/
OSGI-INF/blueprint/
OSGI-INF/blueprint/blueprint.xml
log4j.properties
sql/
sql/import.sql
sql/orm.xml

Environment

  • Red Hat Fuse
    • 7.2

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