Arun, This does now run my test case.. (though it did highlight a minor problem with my SQL statement in the test case.. eg I wrote things like .... 'obj'.'attrib1', 'obj'.'attrib2' .. in the statement - which should not have the single quotes...).
I haven't tried to be rigorous in the tests.. just ensured it returned a result. Thanks, Jon ----- Original Message ----- From: "Arun Sudhakaran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 20, 2002 9:07 AM Subject: Re: [castor-dev] RE: CALL SQL and One to Many relationships problem (fwd) > Hi Jon, > > I'd made some changes in the SQLEngine.java code.I'm attaching the > code with this message,try it,it should solve the problem. > > Arun > ----- Original Message ----- > From: "Jon Ferguson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, September 20, 2002 1:21 PM > Subject: Re: [castor-dev] RE: CALL SQL and One to Many relationships problem > (fwd) > > > > Hey, Bruce, Sudhir, Arun, > > > > Did this get resolved?.. I just re-ran a test case I wrote using the test > > harness to discover this is the same problem I've been > > having with pass through SQL... it fails on line 424 of the SQLEngine > > createCall with a NullPointerException.. > > > > I'm running on PostgreSql. > > > > Here's the test case I'm using which runs in the test harness - under the > > Postgres tests. > > > > Cheers, > > Jon > > > > ----- Original Message ----- > > From: "Bruce Snyder" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Tuesday, September 17, 2002 9:36 PM > > Subject: [castor-dev] RE: CALL SQL and One to Many relationships problem > > (fwd) > > > > > > > ---------- Forwarded message ---------- > > > Date: Sat, 7 Sep 2002 10:55:43 -0700 > > > From: Sudhir Bhojwani <[EMAIL PROTECTED]> > > > To: Arun Sudhakaran <[EMAIL PROTECTED]>, [EMAIL PROTECTED] > > > Subject: RE: CALL SQL and One to Many relationships problem > > > > > > I don't seem to have the same problem as you. I just tried a sample. > > > Obviosuly we have a problem but the > > > location in your case is SQLEngine.createCall...which works fine for me. > > > However, if you can send me the line > > > number in SQLEngine.createCall, it will be helpful. I guess you should > try > > > to run a test case outside any app server > > > domain. Because, I have made quite a few changes in the code I am using > so > > > can't tell you without the li9ne number information. > > > > > > However, there is another problem with relationship. Now the reason: > > > > > > Customer can have 1..n Order defined in the mapping file as: > > > <field name="orders" type="Orders" required="false" > > > collection="arraylist"> > > > <sql many-key="cust_id" /> > > > </field> > > > > > > So, what Castor expects for such relations is to at least load all the > > > related Order IDs when > > > loading a Customer. OQL like "select c from Customer c where c.custId=?" > > get > > > converted into following SQL: > > > "select Customer.cust_name, Order.order_id from Customer, Order where > > > Order.cust_id=Customer.cust_id AND > > > Customer.cust_id=?" > > > > > > Essenitally all the Order IDs for a Customer must be loaded with a given > > > Customer. > > > So, writing a query like "CALL SQL select * from CUSTOMER AS Customer" > > will > > > throw a SQLException. > > > > > > If you are using relationships be careful when you use CALL SQL...as you > > can > > > see. > > > > > > cheers > > > sudhir > > > > > > > > > > > > -----Original Message----- > > > From: Arun Sudhakaran [mailto:[EMAIL PROTECTED]] > > > Sent: Friday, September 06, 2002 11:11 PM > > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > > Subject: CALL SQL and One to Many relationships problem > > > > > > > > > Hi Sudhir,Bruce > > > > > > > > > I'm having a slight problem using CALL SQL with 1-N relationships. I > > > have a Customer having 1-n relation with orders. im attaching the > mapping > > > file also. > > > > > > <!-- Mapping for Customer Context --> > > > <class name="Customer" identity="custId" key-generator="MAX"> > > > <description>Customer</description> > > > <map-to table="Customer" /> > > > <field name="custId" type="long" > > > > <sql name="cust_id" type="bigint"/> > > > </field> > > > <field name="name" type="string"> > > > <sql name="cust_name" type="char"/> > > > </field> > > > <field name="age" type="integer"> > > > <sql name="age" type="integer"/> > > > </field> > > > <field name="orders" type="Orders" required="false" > > > collection="arraylist"> > > > <sql many-key="cust_id" /> > > > </field><!----> > > > </class> > > > > > > > > > <!-- Mapping for Order --> > > > <class name="Orders" identity="Id" key-generator="MAX"> > > > <description>Order</description> > > > <map-to table="orders" /> > > > <field name= "Id" type ="integer"> > > > <sql name="order_id" type="integer"/> > > > </field> > > > <field name= "name" type ="string"> > > > <sql name="name" type="varchar" /> > > > </field> > > > <field name= "customer" type ="Customer" > > > > <sql name="cust_id" /> > > > </field> > > > </class> > > > > > > If i use CALL SQL SELECT * FROM CUSTOMER AS Customer i get the following > > > exception > > > > > > [test] SQL SELECT * FROM CUSTOMER > > > [test] java.lang.NullPointerException > > > [test] java.lang.NullPointerException > > > [test] at org.exolab.castor.jdo.engine.SQLEngine.createCall(Unknown > > Source) > > > [test] at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(Unknown > > Source) > > > [test] at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(Unknown > > Source) > > > [test] at org.exolab.castor.jdo.engine.OQLQueryImpl.execute(Unknown > > Source) > > > [test] at Test.run(Test.java:97) > > > [test] at Test.main(Test.java:58) > > > > > > If i comment out the orders field from Customer mapping it works without > a > > > hitch. The program works fine when i use OQL such as Call a from > Customer > > a. > > > Could you please help me with this. we are in a sort of tight situation. > > > > > > Thanks in advance > > > > > > Arun S > > > > > > ----------------------------------------------------------- > > > If you wish to unsubscribe from this mailing, send mail to > > > [EMAIL PROTECTED] with a subject of: > > > unsubscribe castor-dev > > > > > > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
