Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321649

Summary: on PostgreSQL, 5 JPA tests from jpa.xml & jpa.advanced.multitenant packages failed due to Null Primary keys
Product: z_Archived Reporter: Praba Vijayaratnam <prabaharan.vijayaratnam>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: anji_kansara, jamesssss, marko.kanala, nobody, rodrigo.hjort, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: posgresql
Attachments:
Description Flags
fixes a few platform test failures none

Description Praba Vijayaratnam CLA 2010-08-03 15:43:49 EDT
Following tests failed with same exception on PostgreSQL:
org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.testMergeDetachedObject
org.eclipse.persistence.testing.tests.jpa.xml.merge.inherited.EntityMappingsMergeInheritedJUnitTestCase.testNamedNativeQueryBeerConsumers
org.eclipse.persistence.testing.tests.jpa.xml.merge.inherited.EntityMappingsMergeInheritedJUnitTestCase.testNamedNativeQueryCertifications
org.eclipse.persistence.testing.tests.jpa.xml.advanced.EntityMappingsAdvancedJUnitTestCase.testNamedNativeQueryOnAddress
org.eclipse.persistence.testing.tests.jpa.xml.inheritance.EntityMappingsInheritanceJUnitTestCase.testNamedNativeQueryOnSportsCar

Exception Description: The primary key read from the row [DatabaseRecord( => 3651 => => null)] during the execution of the query was detected to be null. Primary keys must not contain null. Query: ReadAllQuery(name="findAllSQLDepartments" referenceClass=Department sql="select * from CMP3_DEPT")

Local Exception Stack:
Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.2.0.v20100731-r7961): org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRecord(
=> 3651
=>
=> null)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(name="findAllSQLDepartments" referenceClass=Department sql="select * from CMP3_DEPT")
at org.eclipse.persistence.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:868)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:481)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:454)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:721)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:723)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:420)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1074)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:736)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1034)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:380)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1112)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1247)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:479)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:714)
at org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.testMergeDetachedObject(EntityManagerJUnitTestSuite.java:5668)
at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:466)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:208)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
Comment 1 Praba Vijayaratnam CLA 2011-08-10 05:54:33 EDT
also following test failed with same exception:

org.eclipse.persistence.testing.tests.jpa.advanced.multitenant.AdvancedMultiTenantJunitTest.testComplexMultitenantQueries

Exception caught: Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.4.0.v20110809-r9851): org.eclipse.persistence.exceptions.QueryException Exception Description: The primary key read from the row [ArrayRecord( => 801 => Gonzo => 707)] during the execution of the query was detected to be null. Primary keys must not contain null. Query: ReadAllQuery(referenceClass=MafiaFamily sql="select * from JPA_MAFIA_FAMILY")

junit.framework.AssertionFailedError: Exception caught: Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.4.0.v20110809-r9851): org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row [ArrayRecord(
=> 801
=> Gonzo
=> 707)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(referenceClass=MafiaFamily sql="select * from JPA_MAFIA_FAMILY")
at org.eclipse.persistence.testing.tests.jpa.advanced.multitenant.AdvancedMultiTenantJunitTest.testComplexMultitenantQueries(AdvancedMultiTenantJunitTest.java:861)
at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:551)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:211)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
Comment 2 Nobody - feel free to take it CLA 2012-01-11 18:44:28 EST
I also experience this bug.

However, at least for native queries the first released version hitting this bug is 2.3.1-M6, 2.3.2+ also affected:

[2012-01-12T00:11:21.738] FINEST: Execute query ReadAllQuery(referenceClass=AdvancedNetworkEntity sql="SELECT b.* FROM test_network_advanced b WHERE b.c_network >>= #IPADDR")
[2012-01-12T00:11:21.740] FINEST: Connection acquired from connection pool [default].
[2012-01-12T00:11:21.741]  FINER: begin transaction
[2012-01-12T00:11:21.742]   FINE: SELECT b.* FROM test_network_advanced b WHERE b.c_network >>= ?
        bind => [10.10.1.6]
[2012-01-12T00:11:21.742]WARNING: 
Local Exception Stack: 
Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.3.1.v20110921-r10132): org.eclipse.persistence.exceptions.QueryException
Exception Description: The primary key read from the row [ArrayRecord(
         => 2
         => 10.10.0.0/16)] during the execution of the query was detected to be null.  Primary keys must not contain null.
Query: ReadAllQuery(referenceClass=AdvancedNetworkEntity sql="SELECT b.* FROM test_network_advanced b WHERE b.c_network >>= ?")
        at org.eclipse.persistence.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:895)



...with up to 2.3.1-M5 (didn't test pre-2.3.0 releases) I get it correctly:

[2012-01-12T00:14:36.502] FINEST: Execute query ReadAllQuery(referenceClass=AdvancedNetworkEntity sql="SELECT b.* FROM test_network_advanced b WHERE b.c_network >>= #IPADDR")
[2012-01-12T00:14:36.503] FINEST: Connection acquired from connection pool [default].
[2012-01-12T00:14:36.505]  FINER: begin transaction
[2012-01-12T00:14:36.506]   FINE: SELECT b.* FROM test_network_advanced b WHERE b.c_network >>= ?
        bind => [10.10.1.6]
[2012-01-12T00:14:36.509]  FINER: begin unit of work commit
[2012-01-12T00:14:36.510]  FINER: commit transaction
[2012-01-12T00:14:36.511] FINEST: Connection released to connection pool [default].
[2012-01-12T00:14:36.512]  FINER: end unit of work commit
Comment 3 Nobody - feel free to take it CLA 2012-01-11 18:45:41 EST
This bug will also affect all GlassFish 3.1.2 users as it comes with EclipseLink 2.3.2 included.
Comment 4 Nobody - feel free to take it CLA 2012-02-19 12:39:58 EST
I've finally found the time to bisect this problem.

The relevant commit that introduced this bug is 10117 on the 2.3 branch.

After looking into the changes I retried my tests with the 2.3.1-M6 release and added the following to my persistence.xml:

<property name="eclipselink.jpa.uppercase-column-names" value="true"/>

With this, my tests run successfully and the primary key column is being found again.
Comment 5 James Sutherland CLA 2012-06-04 11:38:43 EDT
>> Ancoron

Not sure how this ever worked, at least in a released version, the flag may have been on for a few builds in 2.3.x, but never released as the default.

Are you setting any other settings such as delimiters?  Have you tried 2.3.0, or 2.2?
Comment 6 Nobody - feel free to take it CLA 2012-06-04 16:28:37 EDT
(In reply to comment #5)
> >> Ancoron
> 
> Not sure how this ever worked, at least in a released version, the flag may
> have been on for a few builds in 2.3.x, but never released as the default.
> 
> Are you setting any other settings such as delimiters?  Have you tried 2.3.0,
> or 2.2?

Sorry, I didn't dig that much through the EclipseLink internals yet.

However, I can say that the 2.2.x series is fine as well as 2.3.0 even without the workaround as I am currently running queries like the above in GlassFish 3.1.1 (includes EclipseLink 2.3.0) and previously used GlassFish 3.1.0 (includes EclipseLink 2.2.0 - also upgraded to 2.2.1 for some other bug-fixes).

My settings that I used for this tests are like these (no other configuration used):
<persistence-unit name="test-unit" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>org.ancoron.postgresql.jpa.test.PGinetEntity</class>
    <class>org.ancoron.postgresql.jpa.test.AdvancedNetworkEntity</class>
    <class>org.ancoron.postgresql.jpa.test.NetworkConfiguration</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.PostgreSQLPlatform"/>
        <property name="eclipselink.logging.logger" value="JavaLogger"/>
        <property name="eclipselink.logging.level" value="INFO"/>
        <property name="eclipselink.logging.parameters" value="true"/>
        <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

        <property name="connection.autocommit" value="false"/>
        <property name="eclipselink.persistence-context.flush-mode" value="COMMIT"/>
        <property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
        <property name="eclipselink.jpa.uppercase-column-names" value="true"/>
    </properties>
</persistence-unit>


For the test setup I just create the EntityManagerFactory by supplying only JDBC database, user aso. and create the EntityManager as standard like this:

EntityManager em = emFactory.createEntityManager();

So no other customisation involved here.
Comment 7 James Sutherland CLA 2012-06-05 14:03:39 EDT
The test issue is that Postgres return columns in lower case, but the test column are upper case, so the two do not match.

The user's issue, (this bug is in 2.3), is that we are defaulting to upper casing the column names for comparison in JPA to true, but not default upper casing the database meta-data column to true, so they do not match.  (in 2.4 they should still match as we check both).

main (2.5) should be fixed to be case insensitive by default (upper case both).

>> Ancoron
I assume the following:
- 2.4 work for you,
- using the property below works for you,
<property name="eclipselink.jpa.uppercase-column-names" value="true"/>

If you cannot use the property, you can request a backport of the fix to 2.3.
Comment 8 James Sutherland CLA 2012-06-05 14:04:24 EDT
Created attachment 216862 [details]
fixes a few platform test failures
Comment 9 James Sutherland CLA 2012-06-05 14:05:16 EDT
Fixing to default to upper casing JPA comparison and database column names to true.
Comment 10 James Sutherland CLA 2012-06-05 14:18:27 EDT
SVN trunk commit: Bug#321649 - Postgres case insensitivity, and platform test fixes

https://bugs.eclipse.org/bugs/show_bug.cgi?id=321649

This should fix several of the test failures in the database platform test run.
Bugs, 370995, 337143

Code review: Chris (pending)

Changes:
-	Load server platform with local class loader in addition to application class loader in SessionsFactory (application loader does not work in Glassfish)
-	Check for null in SerializedObjectConverter, to avoid serializing it to bytes.
-	Handle schema in TableCreator for extending table DDL option, if schema match is found, ignore the columns from other schema (fixes failure on DB2)
-	Fixed Vegetable test model to init char field to avoid invalid null ascii character (fails on Posgres)
-	Converted JPA complex aggregate tests to JPA JUnit tests from old framework tests.
-	Fixed JPA inheritance tests from running as old framework tests.
-	Fixed case insensitivity to default correctly and to default to true.
Comment 11 Nobody - feel free to take it CLA 2012-06-06 16:26:22 EDT
Just verified that version 2.4.0-RC1 is fine and I don't have to modify the persistence.xml.

And even in case I do find other trouble with that version I am also fine with the workaround inside the config-file, which is much less intrusive that changing code just to not hit a bug.
Comment 12 Anjani Kansara CLA 2012-06-13 13:32:53 EDT
Hello All,

I need your help. I have developed one J2EE project which were running fine before. Before 2 days ago I have try same project with new version of NetBeans IDE 7.1.2 with GlassFish server 3.2.1.

Now while selecting any records it show me below error.

"during the execution of the query was detected to be null. Primary keys
must not contain null."

I am using MySQL database.

Can you please guide me how can I solve this error.

After some searching on google i come to know that this is the bug in eclipse 2.3 which was default with Netbeans 7.1.2. I have downloaded ecliselink 2.5.
Can you please guide me that i can i reference new eclipse in my project. Or how can i replace eclipse 2.3 with 2.5. 


Thanks for your help in advance.
Comment 13 Nobody - feel free to take it CLA 2012-06-13 17:53:43 EDT
(In reply to comment #12)
> Hello All,
> 
> I need your help. I have developed one J2EE project which were running fine
> before. Before 2 days ago I have try same project with new version of NetBeans
> IDE 7.1.2 with GlassFish server 3.2.1.
> 
> Now while selecting any records it show me below error.
> 
> "during the execution of the query was detected to be null. Primary keys
> must not contain null."
> 
> I am using MySQL database.
> 
> Can you please guide me how can I solve this error.
> 
> After some searching on google i come to know that this is the bug in eclipse
> 2.3 which was default with Netbeans 7.1.2. I have downloaded ecliselink 2.5.
> Can you please guide me that i can i reference new eclipse in my project. Or
> how can i replace eclipse 2.3 with 2.5. 
> 
> 
> Thanks for your help in advance.

If you're deploying your application to GlassFish then you'll have to patch your GlassFish installation or try the workaround as described in comment #4.

To patch the GlassFish installation with a newer EclipseLink version you have to replace the files located in <installation-path>/glassfish/modules/org.eclipse.persistence*.jar

Hope that helps.
Comment 14 Anjani Kansara CLA 2012-06-14 12:16:19 EDT
Dear All,

I have worked around the solution which provided in comment 4 but i could not found such properties in my persistence.xml file.

Here i have one correction i am using glassfish 3.1.2

I found below files at <installation-path>/glassfish/modules/
org.eclipse.persistence.antlr
org.eclipse.persistence.asm
org.eclipse.persistence.core
org.eclipse.persistence.jpa
org.eclipse.persistence.jpa.modelgen
org.eclipse.persistence.moxy
org.eclipse.persistence.oracle


Which files i have to replace ?


In newly downloaded eclipselink 2.5 folder i could not found files with same name.

If you have files which will help me then can you please mail me ? Or please suggest me exact location from where i will download new files ?
Comment 15 James Sutherland CLA 2012-06-14 15:34:45 EDT
Fixed in 2.5.
Comment 16 Anjani Kansara CLA 2012-06-14 20:46:05 EDT
Hello James,

You are right that this bug was fixed in eclipselink 2.5 but i could not found such files with same name which i have replace in module folder as suggest by Ancoron.

Can you please guide me from where i can download this place and how can i reference it to my glassfish server.

In last comments of Ancoron suggest me to replace some files but i could not found same file in my new eclipse 2.5 folder.

Please go through my last updated comment and suggest me what i have to do ?

Thanks for you help in advance.
Comment 17 Anjani Kansara CLA 2012-06-15 00:18:11 EDT
Here i have send you log of my glassfish server .

In log i have found that my persistence is changes from 2.3 to 2.5 after placing some files in module folders.

I placed the files not replaced.

But after upgrading my persistence i got error "Exception while preparing the app : javax/persistence/StoredProcedureQuery"


Launching GlassFish on Felix platform
Jun 15, 2012 6:37:43 AM BundleProvisioner install
WARNING: Failed to install file:/C:/glassfish3/glassfish/modules/org.eclipse.persistence.jpa.equinox.weaving_2.5.0.v20120612-r11659.jar
org.osgi.framework.BundleException: Only the system bundle can have extension bundles.
	at org.apache.felix.framework.util.manifestparser.ManifestParser.parseExtensionBundleHeader(ManifestParser.java:1492)
	at org.apache.felix.framework.util.manifestparser.ManifestParser.checkExtensionBundle(ManifestParser.java:1207)
	at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:267)
	at org.apache.felix.framework.BundleRevisionImpl.<init>(BundleRevisionImpl.java:114)
	at org.apache.felix.framework.BundleImpl.createRevision(BundleImpl.java:1196)
	at org.apache.felix.framework.BundleImpl.<init>(BundleImpl.java:95)
	at org.apache.felix.framework.Felix.installBundle(Felix.java:2732)
	at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
	at com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.install(BundleProvisioner.java:446)
	at com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner.installBundles(BundleProvisioner.java:208)
	at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder.build(OSGiGlassFishRuntimeBuilder.java:139)
	at org.glassfish.embeddable.GlassFishRuntime._bootstrap(GlassFishRuntime.java:157)
	at org.glassfish.embeddable.GlassFishRuntime.bootstrap(GlassFishRuntime.java:110)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
	at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.1.2 (build 23)
INFO: Grizzly Framework 1.9.46 started in: 172ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.46 started in: 125ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.46 started in: 93ms - bound to [0.0.0.0:3700]
INFO: Grizzly Framework 1.9.46 started in: 203ms - bound to [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.46 started in: 78ms - bound to [0.0.0.0:7676]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
SEVERE: CORE10012: Application previously deployed is not at its original location any more: file:/D:/HealthFitness/dist/gfdeploy/HealthFitness/
INFO: GlassFish Server Open Source Edition 3.1.2 (23) startup time : Felix (16,531ms), startup services(3,594ms), total(20,125ms)
INFO: User [] from host localhost does not have administration access
INFO: JMX005: JMXStartupService had Started JMXConnector on JMXService URL service:jmx:rmi://localhost:8686/jndi/rmi://localhost:8686/jmxrmi
INFO: Hibernate Validator 4.2.0.Final
INFO: Grizzly Framework 1.9.46 started in: 15ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.46 started in: 31ms - bound to [0.0.0.0:8181]
WARNING: Originally deployed application at D:\HealthFitness\dist\gfdeploy\HealthFitness not found
WARNING: DPL8027: Ignore WEB-INF/sun-web.xml in archive /D:/HealthFitness/dist/gfdeploy/HealthFitness/HealthFitness-war_war/, as GlassFish counterpart runtime xml WEB-INF/glassfish-web.xml is present in the same archive.
INFO: Created EjbThreadPoolExecutor with thread-core-pool-size 16 thread-max-pool-size 32 thread-keep-alive-seconds 60 thread-queue-capacity 2147483647 allow-core-thread-timeout false 
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: EntityPackage.Payment actually got transformed
INFO: EntityPackage.Emplogin actually got transformed
INFO: EntityPackage.Salary actually got transformed
INFO: EntityPackage.Packselect actually got transformed
INFO: EntityPackage.Empmemreg actually got transformed
INFO: EntityPackage.Memcurrinfo actually got transformed
INFO: EntityPackage.Attendance actually got transformed
INFO: EntityPackage.Timetable actually got transformed
INFO: EntityPackage.Package actually got transformed
INFO: EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20120612-r11659
INFO: file:/D:/HealthFitness/dist/gfdeploy/HealthFitness/HealthFitness-ejb_jar/_HealthFitness-ejbPU login successful
SEVERE: Exception while preparing the app
SEVERE: javax/persistence/StoredProcedureQuery
java.lang.NoClassDefFoundError: javax/persistence/StoredProcedureQuery
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:289)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:304)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:282)
	at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:211)
	at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
	at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
	at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
	at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
	at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
	at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:290)
	at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:86)
	at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:141)
	at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:138)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:215)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:224)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:250)
	at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:138)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
	at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
	at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
	at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:619)

SEVERE: Exception while preparing the app : javax/persistence/StoredProcedureQuery
Comment 18 Marko Kanala CLA 2012-10-28 12:09:22 EDT
(In reply to comment #7)
> <property name="eclipselink.jpa.uppercase-column-names" value="true"/>
> 
> If you cannot use the property, you can request a backport of the fix to 2.3.

Could you please backport this fix to 2.4 and 2.3 branches ? This is a blocker for us as we are using glassfish as a container. Would be greatly appreciated!

We've tried running glassfish with stock 2.3.2 and manually upgraded 2.4.1 and we still encounter case sensitivity issues with postgresql for example when using batch joins. Using the property with 2.3.2 or 2.4.1 does not fix the issue.
Comment 19 Marko Kanala CLA 2012-10-29 08:06:33 EDT
(In reply to comment #18)
> (In reply to comment #7)
> > <property name="eclipselink.jpa.uppercase-column-names" value="true"/>
> > 
> > If you cannot use the property, you can request a backport of the fix to 2.3.
> 
> Could you please backport this fix to 2.4 and 2.3 branches ? This is a
> blocker for us as we are using glassfish as a container. Would be greatly
> appreciated!
> 
> We've tried running glassfish with stock 2.3.2 and manually upgraded 2.4.1
> and we still encounter case sensitivity issues with postgresql for example
> when using batch joins. Using the property with 2.3.2 or 2.4.1 does not fix
> the issue.

To get back to this issue we are having strange issues with postgresql and eclipselink (tested with eclipselink 2.3.2, 2.4.1 and 2.5.0-M4).

We have a basic OneToMany relation hierarchy

A --* B --* C

declared as:

public class A {

...
    @OneToMany(fetch = FetchType.EAGER, mappedBy = "a", cascade = CascadeType.ALL)
    @JoinFetch
    @OrderBy("order ASC")
    private List<B> bs;
}

public class B {
...
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "a_id")
    private A a;

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "b")
    @BatchFetch(BatchFetchType.JOIN)
    @OrderBy("order ASC")
    private List<C> cs;
}

public class C {
...
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "b_id")
    private B b;
}

We are running with postgresql and all column mappings are declared in lower case. BatchFetch annotation in class B does not work. It always fails with

Exception Description: The parameter name [id] in the query's selection criteria does not match any parameter name defined in the query.
Query: ReadAllQuery(name="cs" referenceClass=B sql="SELECT t0.id, t0.description, t0.expected, t0.order, t0.b_id FROM c t0, b t1 WHERE ((t0.b_id = t1.id) AND (t1.a_id = ?)) ORDER BY t0.order ASC")
	at org.eclipse.persistence.exceptions.QueryException.parameterNameMismatch(QueryException.java:1080)
	at org.eclipse.persistence.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:275)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:1057)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:219)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:277)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:672)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2706)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2659)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:422)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1150)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:854)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1109)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:394)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1197)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2877)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1681)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1663)
	at org.eclipse.persistence.mappings.CollectionMapping.executeBatchQuery(CollectionMapping.java:917)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:636)
	at org.eclipse.persistence.mappings.CollectionMapping.extractResultFromBatchQuery(CollectionMapping.java:898)
	at org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromBatchQuery(NoIndirectionPolicy.java:294)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.batchedValueFromRow(ForeignReferenceMapping.java:272)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2099)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.buildCloneFromRow(ForeignReferenceMapping.java:333)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:1726)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:1873)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:721)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:625)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:583)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:567)
	at org.eclipse.persistence.mappings.CollectionMapping.valueFromRowInternalWithJoin(CollectionMapping.java:2542)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow(ForeignReferenceMapping.java:2102)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.buildCloneFromRow(ForeignReferenceMapping.java:333)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoWorkingCopyClone(ObjectBuilder.java:1726)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:1873)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:721)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:625)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:583)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:567)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:777)
	at org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:787)
	at org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:460)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1150)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:854)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1109)
	at org.eclipse.persistence.queries.ReadObjectQuery.execute(ReadObjectQuery.java:421)
...

For some reason eclipselink cannot map the "id" field correctly when reading the database response and I suspect this might have something to do with the issue postgresql reporting the column names in lower case. Our columns _are_ in lower case and I checked all columns are declared with explicit name values so that they don't default to upper case. I tried setting the eclipselink.jpa.uppercase-column-names to both values true and false with no effect.

This occurs only with @BatchFetching and for example @JoinFetch annotations work ok.
Comment 20 Tom Ware CLA 2012-10-29 09:11:15 EDT
Have you tried 2.5?  Here are some instructions for updating EclipseLink in GlassFish:

https://blogs.oracle.com/GlassFishPersistence/entry/updating_eclipselink_bundles_in_glassfish

If 2.5 does not solve the issue, you should file a separate bug.  If 2.5 solves it, all this bug fix does is change a default for a persistence unit property.  It changes the default for "eclipselink.jpa.uppercase-column-names" from false to true.  You will get the same effect by explicitly putting the setting in your persistence unit.
Comment 21 Marko Kanala CLA 2012-10-29 11:53:03 EDT
(In reply to comment #20)
> 
> If 2.5 does not solve the issue, you should file a separate bug.

Tried with 2.5.0-M4 and problem persists. Submitted bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=393065
Comment 22 Chris Delahunt CLA 2012-11-21 12:29:52 EST
*** Bug 296791 has been marked as a duplicate of this bug. ***
Comment 23 Eclipse Webmaster CLA 2022-06-09 10:35:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink