Community
Participate
Working Groups
The query backing a relationship that involves columns referenced in an embedded id does not properly quote columns in the where clause. This results in platform-specific behaviour (depending on how the database handles unquoted identifiers). It appers that DatabaseField.useDelimiters is not set correctly when associations reference columns in an embedded id and <delimited-identifiers/> is in the orm.xml A sample project with associated JUnit test is attached. In this example, the SQL is generated as follows: bc. SELECT "a_id", "c_id" FROM "B" WHERE (a_id = ?) notice that a_id is not quoted in the where clause. Quoted identifiers should always be used when <delimited-identifiers/> is specified in the orm.xml The full stack trace from running the attached JUnit test follows: pre.. Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: user lacks privilege or object not found: A_ID Error Code: -5501 Call: SELECT "a_id", "c_id" FROM "B" WHERE (a_id = ?) bind => [1] Query: ReadAllQuery(name="bs" referenceClass=B sql="SELECT "a_id", "c_id" FROM "B" WHERE (a_id = ?)") at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:687) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:530) at org.eclipse.persistence.internal.sessions.AbstractSession.executeCall(AbstractSession.java:914) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:262) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:618) at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2537) at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2496) at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:455) at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997) at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675) at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958) at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432) at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2857) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207) at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:85) at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiateForUnitOfWorkValueHolder(QueryBasedValueHolder.java:100) at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:156) at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230) at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83) at org.eclipse.persistence.indirection.IndirectSet.buildDelegate(IndirectSet.java:192) at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:343) at org.eclipse.persistence.indirection.IndirectSet.size(IndirectSet.java:500) at eclipselinktest.domain.JpaTest.testAssociationCanLoad(JpaTest.java:48) 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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.sql.SQLException: user lacks privilege or object not found: A_ID at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:248) at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:302) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1404) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1353) at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:645) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:580) ... 54 more Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: A_ID at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source) at org.hsqldb.QueryExpression.resolve(Unknown Source) at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source) at org.hsqldb.ParserCommand.compilePart(Unknown Source) at org.hsqldb.ParserCommand.compileStatement(Unknown Source) at org.hsqldb.Session.compileStatement(Unknown Source) at org.hsqldb.StatementManager.compile(Unknown Source) at org.hsqldb.Session.execute(Unknown Source) ... 62 more p. Missing from the attachment is binary jar files: /eclipselink-test/lib/eclipselink-src.zip /eclipselink-test/lib/eclipselink.jar /eclipselink-test/lib/hsqldb-src.zip /eclipselink-test/lib/hsqldb.jar /eclipselink-test/lib/javax.persistence_2.0.0.v201002051058.jar /eclipselink-test/lib/javax.persistence.source_2.0.0.v200911271158.jar /eclipselink-test/lib/jcl-over-slf4j-1.5.11.jar /eclipselink-test/lib/log4j-1.2.16.jar /eclipselink-test/lib/slf4j-api-1.5.11.jar /eclipselink-test/lib/slf4j-log4j12-1.5.11.jar And a reference to Spring 3 libraries. I've set the bug to major severity, since it prevents the use of EclipseLink in such scenarios.
Created attachment 174227 [details] project with JUnit that demonstrates the problem
any pointers on where I might look to get started in creating a patch?
>Patches are welcome - if you mean a diff of proposed code changes. >general building EclipseLink wiki (which projects are relevant) http://wiki.eclipse.org/EclipseLink/Building >How to checkout the SVN repository (anonymous) and develop using Eclipse http://wiki.eclipse.org/EclipseLink/Source#EclipseLink_Source_Control_Repositories http://wiki.eclipse.org/EclipseLink/Development/Testing/Prereq >optimize your SVN install http://wiki.eclipse.org/EclipseLink/Building/Optimize - after installing TortoiseSVN, right click on the source root and select "create patch"
Thanks for the pointers. Currently blocked on bug 321277: Java Builder crashes when building EclipseLink from source https://bugs.eclipse.org/bugs/show_bug.cgi?id=321277
>See Eclipse 3.5 32/64 bit on SUN, JRockit and J9 1.6 JVM configurations that work in bug# 321277 comment >See also all fixes for known issues running on 64-bit installs - if you require this.
http://wiki.eclipse.org/EclipseLink/Building/64bit
>temp raising to P2 critical (from P3 major) until user is unblocked by Helios issues in bug# 321277 or reverts to using Galileo
Setting target and priority. See the following page for details of the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Some spots the global identifier for delimiting was not checked have been corrected in patches for 299926 and 316045 (checked into 2.1 and 2.1.1 respectively). I have verified the test case passes in the latest EclipseLink version due to the fix from 316045. *** This bug has been marked as a duplicate of bug 316045 ***
fantastic, thanks!
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink