Community
Participate
Working Groups
testUpdateUsingTempStorageWithParameter failed on derby 10 Stack Trace: ============t Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "NULL" at line 1, column 111. Error Code: 20000 Call: INSERT INTO session.TL_CMP3_EMPLOYEE (EMP_ID, VERSION, ADDR_ID, ROOM_NUM) SELECT t0.EMP_ID, (t0.VERSION + 1), NULL, t1.SALARY FROM CMP3_EMPLOYEE t0, CMP3_SALARY t1 WHERE ((t0.F_NAME = 'testUpdateUsingTempStorage') AND (t1.EMP_ID = t0.EMP_ID)) Query: UpdateAllQuery(referenceClass=Employee sql="DECLARE GLOBAL TEMPORARY TABLE session.TL_CMP3_SALARY (EMP_ID INTEGER, SALARY INTEGER) ON COMMIT DELETE ROWS NOT LOGGED") Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.1.1.qualifier): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "NULL" at line 1, column 111. Error Code: 20000 Call: INSERT INTO session.TL_CMP3_EMPLOYEE (EMP_ID, VERSION, ADDR_ID, ROOM_NUM) SELECT t0.EMP_ID, (t0.VERSION + 1), NULL, t1.SALARY FROM CMP3_EMPLOYEE t0, CMP3_SALARY t1 WHERE ((t0.F_NAME = 'testUpdateUsingTempStorage') AND (t1.EMP_ID = t0.EMP_ID)) Query: UpdateAllQuery(referenceClass=Employee sql="DECLARE GLOBAL TEMPORARY TABLE session.TL_CMP3_SALARY (EMP_ID INTEGER, SALARY INTEGER) ON COMMIT DELETE ROWS NOT LOGGED") at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:323) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:767) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:833) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:558) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:501) at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:872) at org.eclipse.persistence.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:132) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.updateAllUsingTempTables(DatasourceCallQueryMechanism.java:751) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.updateAll(DatasourceCallQueryMechanism.java:713) at org.eclipse.persistence.queries.UpdateAllQuery.executeDatabaseQuery(UpdateAllQuery.java:153) at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:664) at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:583) at org.eclipse.persistence.queries.ModifyAllQuery.executeInUnitOfWork(ModifyAllQuery.java:144) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2755) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1181) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1165) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1139) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:424) at org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.internalUpdateUsingTempStorage(EntityManagerJUnitTestSuite.java:5485) at org.eclipse.persistence.testing.tests.jpa.advanced.EntityManagerJUnitTestSuite.testUpdateUsingTempStorageWithParameter(EntityManagerJUnitTestSuite.java:5440) at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:359) Caused by: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "NULL" at line 1, column 111. at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:756) Caused by: java.sql.SQLException: Syntax error: Encountered "NULL" at line 1, column 111. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) Caused by: ERROR 42X01: Syntax error: Encountered "NULL" at line 1, column 111. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
Using NULL in selects isn't allowed in Derby. As a workaround, you can use a cast, for instance SELECT myCol, CAST(NULL AS INT) FROM ... Another option is to request that Derby allows NULL in selects by creating a Jira issue at https://issues.apache.org/jira/browse/DERBY
After a further investigation, I found that we need to add database-platform class in sessions.xml for server. Because when the tests are running outside container, we pass in <jvmarg value="${jvmarg.db.platform}"/> in "run-test" target, but we don't pass in db.platform in "server-run-test" target. So following parts need to be added to sessions.xml: <login xsi:type="database-login"> <platform-class>org.eclipse.persistence.platform.database.DerbyPlatform</platform-class> </login>
I am sorry that I put comment to the wrong bug, please ignore my previous comments.
This should be fixed now.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink