There seem to be some problem with StoredProcedure stuff in
SQLEngine. Following change in SQLEngine.java helped...



-----Original Message-----
From: Bruce Snyder [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 11, 2002 8:47 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] CALL SQL and One to Many relationships problem


This one time, at band camp, Brett Cherrington said:

Brett, 

Please see my comments inline. 

BC><class name="myObject" identity="id">
BC>
BC><description></description>
BC>
BC><map-to table="dev.object" />
BC>
BC>
BC><field name="a" type="string" >
BC>
BC><sql name="a" type="varchar"/>
BC>
BC></field>
BC>
BC>
BC><field name="b" type="string" >
BC>
BC><sql name="b" type="varchar"/>
BC>
BC></field>
BC>
BC>
BC><field name="c" type="cObject" collection="collection" lazy="true"
required="false">
BC>
BC><sql many-key="mid"/>
BC>
BC></field>
...
BC></class>
BC>
BC>I am then using the following OQL to query for the objects 
BC>
BC>CALL SQL SELECT id, a, b FROM dev.object AS myObject

The CALL SQL requires that the select statement list fields in the order
in which they appear in the mapping descriptor. The mapping descriptor
posted above does not include the id field other than noting that it is
the identity. There is no separate <field> element.

BC>I expected this to return me the objects but without the cObjects (as I
havn't done the INNER JOIN)...??? Is this correct...?

This should be what is returned. 

BC>However, first of all I get a NullPointerException in createCall in
SQLEngine because I havn't provided a sql name attribute for the many object
in my myObject class....I have done a quick fix for this but it leads to
another problem.....In SQLTypes it appears to still try and populate the
many fields in getObject() so fails with a SQLException: Invalid column
index....

This seems odd. Are you relations bi-directional? Can you post the full
stack trace? 

Bruce
-- 
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

==== 
//depot/everest/main/sw/thirdparty/castor/src/main/org/exolab/castor/jdo/engine/SQLEngine.java#2
 - 
/home/sbhojwani/src/everest/main/sw/thirdparty/castor/src/main/org/exolab/castor/jdo/engine/SQLEngine.java
 ====
412a413,418
>         // changes for the SQL Direct interface begins here
>         if(spCall.startsWith("SQL")){
>             sql =spCall.substring(4);
>             return new SQLQuery( this, sql, types );
>         }
>         //this is for stored procedure
417d422
< 
433,441c438
<         // changes for the SQL Direct interface begins here
<         if(spCall.startsWith("SQL")){
<             sql =spCall.substring(4);
<             return new SQLQuery( this, sql, types );
<         } else{
<             return ((BaseFactory) _factory).getCallQuery( spCall, 
types,_clsDesc.getJavaClass(), jdoFields, sqlTypes );
<         }
< 
<        
---
>         return ((BaseFactory) _factory).getCallQuery( spCall, 
>types,_clsDesc.getJavaClass(), jdoFields, sqlTypes );

Reply via email to