History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-836
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Werner Guttmann
Reporter: Martin Fuchs
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
castor

NullPointerException for pass through SQL in query with master detail relation

Created: 24/Jul/04 08:36 AM   Updated: 19/Apr/05 10:52 AM
Component/s: JDO
Affects Version/s: 0.9.5.3
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File castor.properties (0.0 kb)
2. XML File database.xml (0.5 kb)
3. XML File dbmapping.xml (2 kb)
4. Java Source File Dept.java (0.1 kb)
5. Java Source File DeptEmp.java (2 kb)
6. Java Source File DeptEmp.java (2 kb)
7. Java Source File Emp.java (0.3 kb)
8. Text File sqlengline-call-sql-nullpointer.patch (2 kb)

Environment:
Operating System: All
Platform: All

Bugzilla Id: 1696


 Description  « Hide
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=?



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Martin Fuchs - 24/Jul/04 08:37 AM
Created an attachment (id=593)
DeptEmp.java

Martin Fuchs - 24/Jul/04 08:37 AM
Created an attachment (id=594)
Dept.java

Martin Fuchs - 24/Jul/04 08:37 AM
Created an attachment (id=595)
Emp.java

Martin Fuchs - 24/Jul/04 08:38 AM
Created an attachment (id=596)
database.xml

Martin Fuchs - 24/Jul/04 08:38 AM
Created an attachment (id=597)
dbmapping.xml

Martin Fuchs - 24/Jul/04 08:39 AM
Created an attachment (id=598)
castor.properties

Nick Stuart - 03/Aug/04 06:33 AM
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.


Martin Fuchs - 06/Aug/04 10:46 AM
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.


Martin Fuchs - 06/Aug/04 10:46 AM
Created an attachment (id=611)
Patch for org/exolab/castor/jdo/engine/SQLEngine.java

Martin Fuchs - 06/Aug/04 10:49 AM
Created an attachment (id=612)
corrected version of DeptEmp.java

Werner Guttmann - 09/Aug/04 08:15 AM
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.

Werner Guttmann - 09/Aug/04 08:37 AM
Just added a dependency on bug 1628, as clearly this problem would be resolved
without any work if we committed bug 1628.

Bruce Snyder (bugzilla) - 10/Aug/04 06:36 AM
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.

Martin Fuchs - 10/Aug/04 08:48 AM
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.


Werner Guttmann - 11/Aug/04 03:17 AM
Martin, can you please provide me with the DDL you've use to craete the tables
DEPT and EMP.

Werner Guttmann - 11/Aug/04 03:18 AM
Actually, I am sure that my comment above about bug 628 should have gone
elsewhere .. . Problem is that I cannot remember where .. .

Werner Guttmann - 11/Aug/04 03:20 AM
Removed dependency on bug 1628 (as it was wrong).

Martin Fuchs - 11/Aug/04 10:12 AM
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


Werner Guttmann - 01/Sep/04 02:38 AM
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 ?


Bruce Snyder (bugzilla) - 02/Sep/04 09:57 AM
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.

Werner Guttmann - 02/Sep/04 12:37 PM
Patch supplied as provided (plus a minor addition to message.properties). Please
do not forget to close this bug once verified successfully.

Martin Fuchs - 02/Sep/04 01:41 PM
OK, thanks for the commit.

Could you please also correct my name in the CHANGELOG file - it's twice
spelled "Matrin" instead of "Martin".


Werner Guttmann - 02/Sep/04 02:03 PM
Will do en un segundo ... sorry for the name change. Though I'd advise to listen
to a song named' Family Name' by Prince ... .

Werner Guttmann - 06/Sep/04 12:38 AM
Name spelling 'fix' committed. Sorry for the name change ... .

Werner Guttmann - 12/Sep/04 01:15 PM
      • Bug 1288 has been marked as a duplicate of this bug. ***