|
|
NullPointerException for pass through SQL in query with master detail relation |
Query page
Enter new bug
Hello,
the attached small example program connects to the Oracle "SCOTT" schema and
tries to read datasets from the tables DEPT and EMP.
When using the OQL query "SELECT x FROM Dept x WHERE DNAME=$1" with $1="SALES"
all is OK. But when issuing the identical query using call through SQL
statement, I am getting the following NullPointer exception:
0 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Creating class: Dept
using SQL: INSERT INTO "DEPT" ("DEPTNO","DNAME","LOC") VALUES (?,?,?)
0 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Removing class: Dept
using SQL: DELETE FROM "DEPT" WHERE "DEPTNO"=?
16 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Updating class: Dept
using SQL: UPDATE "DEPT" SET "DNAME"=?,"LOC"=? WHERE "DEPTNO"=? AND "DNAME"=?
AND "LOC"=?
31 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Loading class: Dept
using SQL: SELECT "DEPT"."DNAME","DEPT"."LOC","EMP"."EMPNO" FROM "DEPT","EMP"
WHERE "DEPT"."DEPTNO"="EMP"."DEPTNO"(+) AND "DEPT"."DEPTNO"=?
109 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Creating class: Emp
using SQL: INSERT INTO "EMP"
("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO") VALUES
(?,?,?,?,?,?,?,?)
109 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Removing class: Emp
using SQL: DELETE FROM "EMP" WHERE "EMPNO"=?
109 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Updating class: Emp
using SQL: UPDATE "EMP"
SET "ENAME"=?,"JOB"=?,"MGR"=?,"HIREDATE"=?,"SAL"=?,"COMM"=?,"DEPTNO"=?
WHERE "EMPNO"=? AND "ENAME"=? AND "JOB"=? AND "MGR"=? AND "HIREDATE"=?
AND "SAL"=? AND "COMM"=? AND "DEPTNO"=?
109 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Loading class: Emp
using SQL:
SELECT "EMP"."ENAME","EMP"."JOB","EMP"."MGR","EMP"."HIREDATE","EMP"."SAL","EMP".
"COMM","EMP"."DEPTNO" FROM "EMP" WHERE "EMP"."EMPNO"=?
203 [main] DEBUG org.exolab.castor.persist.cache.CountLimited - Successfully
created count-limited cache instance
203 [main] DEBUG org.exolab.castor.persist.cache.CacheFactory - Creating cache
instance for type count-limited
234 [main] DEBUG org.exolab.castor.persist.cache.CountLimited - Successfully
created count-limited cache instance
234 [main] DEBUG org.exolab.castor.persist.cache.CacheFactory - Creating cache
instance for type count-limited
java.lang.NullPointerException
at org.exolab.castor.jdo.engine.SQLEngine.createCall(SQLEngine.java:416)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:499)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:459)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute
(OQLQueryImpl.java:451)
at DeptEmp.run(DeptEmp.java:50)
at DeptEmp.main(DeptEmp.java:12)
359 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Stored procedure
call SQL: SQL SELECT DEPT.DNAME,DEPT.LOC,EMP.EMPNO FROM DEPT,EMP WHERE
DEPT.DEPTNO=EMP.DEPTNO(+) AND DEPT.DEPTNO=?
------- Additional Comment
#1 From
Martin Fuchs
2004-07-24 08:37 -------
Created an attachment (id=593)
DeptEmp.java
------- Additional Comment
#2 From
Martin Fuchs
2004-07-24 08:37 -------
Created an attachment (id=594)
Dept.java
------- Additional Comment
#3 From
Martin Fuchs
2004-07-24 08:37 -------
Created an attachment (id=595)
Emp.java
------- Additional Comment
#4 From
Martin Fuchs
2004-07-24 08:38 -------
Created an attachment (id=596)
database.xml
------- Additional Comment
#5 From
Martin Fuchs
2004-07-24 08:38 -------
Created an attachment (id=597)
dbmapping.xml
------- Additional Comment
#6 From
Martin Fuchs
2004-07-24 08:39 -------
Created an attachment (id=598)
castor.properties
------- Additional Comment
#7 From
Nick Stuart
2004-08-03 06:33 -------
Was doing a little debugging on this and figured out whats going on. For some
reason castor doesnt like the _employees field. It always give it an SQL Name of
null. I added some debugging output right before the last line in the trace in
SQLEngine and here's what I get for output:
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Stored procedure call
SQL: SQL SELECT DEPT.DNAME,DEPT.LOC,EMP.EMPNO FROM DEPT,EMP WHERE DEPT.
DEPTNO=EMP.DEPTNO AND DEPT.DEPTNO=?
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Field: DNAME
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - SQL NAME: [Ljava.
lang.String; at a37368
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Field: LOC
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - SQL NAME: [Ljava.
lang.String; at edc3a2
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - Field: _employees
100 [main] DEBUG org.exolab.castor.jdo.engine.SQLEngine - SQL NAME: null
java.lang.NullPointerException
at org.exolab.castor.jdo.engine.SQLEngine.createCall(SQLEngine.java:418)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:499)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:459)
at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:451)
The SQLname[] array is apparently null, while you can see the other ones arent.
So when the engine goes to get the first element of the array it barfs.
Not sure where to go from here, but I'll poke around some more.
------- Additional Comment
#8 From
Martin Fuchs
2004-08-06 10:46 -------
I tried the modified version of SQLEngine.java attached to bug 1288 - and it
seems this works. So I recommend committing this modification.
To make things easier I will create and attach a patch to be applied to the
current CVS code.
I will also attach a updated version of my test case file DeptEmp.java, because
it has a mistake in it.
------- Additional Comment
#9 From
Martin Fuchs
2004-08-06 10:46 -------
Created an attachment (id=611)
Patch for org/exolab/castor/jdo/engine/SQLEngine.java
------- Additional Comment
#10 From
Martin Fuchs
2004-08-06 10:49 -------
Created an attachment (id=612)
corrected version of DeptEmp.java
------- Additional Comment
#11 From
Werner Guttmann
2004-08-09 08:15 -------
Martin, I will have a look at your patch tonight or tomorrow night. I'll keep
you posted about any progress I make through this report.
------- Additional Comment
#12 From
Werner Guttmann
2004-08-09 08:37 -------
Just added a dependency on bug 1628, as clearly this problem would be resolved
without any work if we committed bug 1628.
------- Additional Comment
#13 From
Bruce Snyder
2004-08-10 06:36 -------
I vaguely remember Mickael was dealing with this. However, upon looking at the
diff between the attached file and the current version in CVS, it will take some
time to sort out because the time difference between the two version is almost
1.5 years. I simply don't have the time at the moment.
------- Additional Comment
#14 From
Martin Fuchs
2004-08-10 08:48 -------
Please look at my attached Patch file:
http://bugzilla.exolab.org/showattachment.cgi?attach_id=611
I already merged the changes of bug 1627 into the current CVS code.
So it should be no problem to use the new patch file and commit the change.
------- Additional Comment
#15 From
Werner Guttmann
2004-08-11 03:17 -------
Martin, can you please provide me with the DDL you've use to craete the tables
DEPT and EMP.
------- Additional Comment
#16 From
Werner Guttmann
2004-08-11 03:18 -------
Actually, I am sure that my comment above about bug 628 should have gone
elsewhere .. :-(. Problem is that I cannot remember where .. ;-).
------- Additional Comment
#17 From
Werner Guttmann
2004-08-11 03:20 -------
Removed dependency on bug 1628 (as it was wrong).
------- Additional Comment
#18 From
Martin Fuchs
2004-08-11 10:12 -------
The tables EMP and DEPT are part of the famous SCOTT example schema of oracle
databases.
You can find a script to generate this schema at the OTN site:
http://www.oracle.com/technology/sample_code/tech/sql_plus/htdocs/demobld.html
------- Additional Comment
#19 From
Werner Guttmann
2004-09-01 02:38 -------
Gentlemen (iow dear fellow committers and wanna-bes), can I please get some
voting done on this patch ? I've integrated the patch, used Martin's donations
as a test case, and run the Castor JDO test suite successfully. Any objections ?
Any other comments ?
------- Additional Comment
#20 From
Gregory Block
2004-09-01 03:04 -------
Looks like a positive change to me.
------- Additional Comment
#21 From
Bruce Snyder
2004-09-02 09:57 -------
The patch *looks* good, but I haven't *applied* it to be tested yet. As long as
it doesn't break any exiting tests, I think it's safe to commit.
------- Additional Comment
#22 From
Werner Guttmann
2004-09-02 12:37 -------
Patch supplied as provided (plus a minor addition to message.properties). Please
do not forget to close this bug once verified successfully.
------- Additional Comment
#23 From
Martin Fuchs
2004-09-02 13:41 -------
OK, thanks for the commit.
Could you please also correct my name in the CHANGELOG file - it's twice
spelled "Matrin" instead of "Martin". ;-)
------- Additional Comment
#24 From
Werner Guttmann
2004-09-02 14:03 -------
Will do en un segundo ... sorry for the name change. Though I'd advise to listen
to a song named' Family Name' by Prince ... ;-).
------- Additional Comment
#25 From
Werner Guttmann
2004-09-06 00:38 -------
Name spelling 'fix' committed. Sorry for the name change ... ;-).
------- Additional Comment
#26 From
Werner Guttmann
2004-09-12 13:15 -------
*** Bug 1288 has been marked as a duplicate of this bug. ***
Query page
Enter new bug
This is Bugzilla: the Mozilla bug system. For more
information about what Bugzilla is and what it can do, see
bugzilla.org.
|
|