sql - javax.persistence.PersistenceException: [PersistenceUnit: NG] Error while reading JPA XML file: META-INF/SQLQueries.xml -


i have tried several suggested methods resolve java persistence exception have not been successful yet. suggestions or appreciated.

below details

sqlqueries.xml -----------------------------  <?xml version="1.0" encoding="utf-8"?> <entity-mappings      xmlns="http://java.sun.com/xml/ns/persistence"      xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/persistence      http://java.sun.com/xml/ns/persistence/orm_2_0.xsd "     version="2.0">      <sql-query name="get_next_num_sp" callable="true">         <return alias = "nextnumber" class="com.utility.numbergenerator.da.numberdaoimpl">         <return-property name="nextseqnum" column="next_seq_num" />     </return>         { ? = call test_proc }     </sql-query>      </entity-mappings> 

persistence.xml -----------------------  <?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/persistence     http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"     version="2.0">      <persistence-unit name="ng" transaction-type="resource_local">         <provider>org.hibernate.ejb.hibernatepersistence</provider>         <mapping-file>meta-inf/sqlqueries.xml</mapping-file>         <class> several related classes </class>         <properties> followed properties </properties>     </persistence-unit> 

stack trace of exception

-- initializing database connection -- javax.persistence.persistenceexception: [persistenceunit: ng] error while reading jpa xml file: meta-inf/sqlqueries.xml @ org.hibernate.ejb.ejb3configuration.addclassestosessionfactory(ejb3configuration.java:1205) @ org.hibernate.ejb.ejb3configuration.configure(ejb3configuration.java:1004) @ org.hibernate.ejb.ejb3configuration.configure(ejb3configuration.java:282) @ org.hibernate.ejb.ejb3configuration.configure(ejb3configuration.java:366) @ org.hibernate.ejb.hibernatepersistence.createentitymanagerfactory(hibernatepersistence.java:56) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:48) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:32) @ com.go2uti.oneworld.common.hibernate.hibernateutil.initializejpa(hibernateutil.java:68) @ com.go2uti.oneworld.common.hibernate.hibernateutil.(hibernateutil.java:38) @ com.go2uti.oneworld.utility.businessidgenerator.da.entitymanagerfactorysingleton.init(entitymanagerfactorysingleton.java:26) @ com.go2uti.oneworld.utility.businessidgenerator.compatibility.abstractpersistenttest.initializecontext(abstractpersistenttest.java:38) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:45) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:15) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:42) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:27) @ org.junit.internal.runners.statements.runafters.evaluate(runafters.java:30) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:263) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:68) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:47) @ org.junit.runners.parentrunner$3.run(parentrunner.java:231) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:60) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:229) @ org.junit.runners.parentrunner.access$000(parentrunner.java:50) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:222) @ org.junit.runners.parentrunner.run(parentrunner.java:300) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:50) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197) caused by: org.hibernate.invalidmappingexception: unable read xml @ org.hibernate.util.xml.mappingreader.readmappingdocument(mappingreader.java:101) @ org.hibernate.cfg.configuration.add(configuration.java:513) @ org.hibernate.cfg.configuration.add(configuration.java:509) @ org.hibernate.cfg.configuration.add(configuration.java:716) @ org.hibernate.cfg.configuration.addresource(configuration.java:801) @ org.hibernate.cfg.annotationconfiguration.addresource(annotationconfiguration.java:152) @ org.hibernate.ejb.ejb3configuration.addclassestosessionfactory(ejb3configuration.java:1192) ... 34 more

please me resolve issue.

your meta-inf/sqlqueries.xml file based on jpa 2.0 xml mapping schema defined http://java.sun.com/xml/ns/persistence/orm_2_0.xsd.

since sql-query element hibernate specific need replace <entity-mappings> <hibernate-mapping> shown below:

<?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public   "-//hibernate/hibernate mapping dtd//en"  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">   <hibernate-mapping>      <sql-query name="get_next_num_sp" callable="true">         <return alias="nextnumber" class="com.utility.numbergenerator.da.numberdaoimpl">             <return-property name="nextseqnum" column="next_seq_num" />         </return>         { ? = call test_proc }     </sql-query>  </hibernate-mapping> 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -