NullPointerException When Result-Set-Mapping Element Is Not Present (Orm.Xml) (Doc ID 947828.1)

Last updated on JANUARY 17, 2014

Applies to:

Oracle TopLink - Version 11.1.1.0.1 and later
Information in this document applies to any platform.
***Checked for relevance on 17-JAN-2014***

Symptoms

In the orm.xml file a native named query  is defined as  :

<entity name="Entity1" class="test.Entity1">

<table name="TESTTable1" />
<named-native-query name="entity1Query" >
<query>
SELECT *
FROM TESTTable1
</query>
</named-native-query>

</entity>


When creating an entity manager (emf.createEntityManager ())  With, EclipseLink 1.1.1,  NullPointerException exception occurs :

javax.persistence.PersistenceException: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [simple-data] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:270)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:123)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:172)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:160)
at test.NamedNativeQuery.dynamicNative(NamedNativeQuery.java:14)
...
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [simple-data] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:236)
... 24 more
Caused by: Exception [EclipseLink-28019] (Eclipse Persistence Services): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [simple-data] failed.
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:218)
... 25 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.metadata.queries.NamedNativeQueryMetadata.process(NamedNativeQueryMetadata.java:120)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processQueries(MetadataProject.java:835)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.addNamedQueries(MetadataProcessor.java:109)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:215)
... 24 more

namedNative(test.NamedNativeQuery)
javax.persistence.PersistenceException: Exception [EclipseLink-28017] (Eclipse Persistence Services):
org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Unable to predeploy PersistenceUnit [simple-data] in invalid state [DeployFailed]
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:690)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:164)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:67)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:158)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:132)
at test.NamedNativeQuery.namedNative(NamedNativeQuery.java:25)
...
Caused by: Exception [EclipseLink-28017] (Eclipse Persistence Services): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Unable to predeploy PersistenceUnit [simple-data] in invalid state [DeployFailed]
at org.eclipse.persistence.exceptions.EntityManagerSetupException.cannotPredeploy(EntityManagerSetupException.java:202)
... 26 more


This problem does not occur when the native query is defined with the (option) result-set-mapping attribute:
<named-native-query name="entity1Query" result-set-mapping="test.Entity1" >


.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms