The following test case uses this data table:
CREATE TABLE A(NR_A INTEGER);
INSERT INTO A VALUES(1);
INSERT INTO A VALUES(2);
INSERT INTO A VALUES(3);
INSERT INTO A VALUES(4);
INSERT INTO A VALUES(5);
INSERT INTO A VALUES(6);
INSERT INTO A VALUES(7);
INSERT INTO A VALUES(8);
COMMIT;
When running the test with the current Castor version, this exception is thrown:
org.exolab.castor.jdo.PersistenceException: Nested error:
java.sql.SQLException: Table not found: A_F0 in statement [SELECT
A.NR_A,A_f0.NR_A FROM A LEFT OUTER JOIN A_f0 ON (A.NR_A=A_f0.NR_A)] while
executing SELECT A.NR_A,A_f0.NR_A FROM A LEFT OUTER JOIN A_f0 ON
(A.NR_A=A_f0.NR_A): Table not found: A_F0 in statement [SELECT A.NR_A,A_f0.NR_A
FROM A LEFT OUTER JOIN A_f0 ON (A.NR_A=A_f0.NR_A)]
at org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.execute
(SQLEngine.java:1788)
at org.exolab.castor.persist.TransactionContext.query
(TransactionContext.java:742)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:474)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:426)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:418)
at test1379.Test1379.run(Test1379.java:66)
at test1379.Test1379.main(Test1379.java:22)
Caused by: java.sql.SQLException: Table not found: A_F0 in statement [SELECT
A.NR_A,A_f0.NR_A FROM A LEFT OUTER JOIN A_f0 ON (A.NR_A=A_f0.NR_A)]
at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.execute
(SQLEngine.java:1762)
... 6 more
Caused by: java.sql.SQLException: Table not found: A_F0 in statement [SELECT
A.NR_A,A_f0.NR_A FROM A LEFT OUTER JOIN A_f0 ON (A.NR_A=A_f0.NR_A)]
at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.execute
(SQLEngine.java:1762)
at org.exolab.castor.persist.TransactionContext.query
(TransactionContext.java:742)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:474)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:426)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:418)
at test1379.Test1379.run(Test1379.java:66)
at test1379.Test1379.main(Test1379.java:22)
Caused by: java.sql.SQLException: Table not found: A_F0 in statement [SELECT
A.NR_A,A_f0.NR_A FROM A LEFT OUTER JOIN A_f0 ON (A.NR_A=A_f0.NR_A)]
at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.exolab.castor.jdo.engine.SQLEngine$SQLQuery.execute
(SQLEngine.java:1762)
at org.exolab.castor.persist.TransactionContext.query
(TransactionContext.java:742)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:474)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:426)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:418)
at test1379.Test1379.run(Test1379.java:66)
at test1379.Test1379.main(Test1379.java:22)
After applying the patch, the test runs successfull and prints:
A.NR_A=1
A.NR_A=2
A.NR_A=3
A.NR_A=4
A.NR_A=5
A.NR_A=6
A.NR_A=7
A.NR_A=8
Please don't look too tight into the test - it is of no practical use and uses
a 1:n mapping from A to A.
Created an attachment (id=313)
A proposed patch to HsqlQueryExpression class, hopefully solving the problem of incorrect table aliases.