This one time, at band camp, Advincula, Eric said:

AE>I'm trying to understand one-to-one query with castor.  I'm trying to access
AE>data from one table to another.
AE>
AE>I hava the following map
AE>
AE><class name="org.funds.Application" identity="applicationId">
AE>  <map-to table="Application"/>
AE>  
AE>  <field name="applicationId" type="integer">
AE>    <sql name="Application_Id" type="integer" />
AE>  </field>
AE>
AE>  <field name="fundName" type="string">
AE>    <sql name="Fund_Name" type="varchar" />
AE>  </field>
AE>... 
AE></class>
AE>
AE><class name="org.funds.ClassCat" identity="classId">
AE>  <map-to table="ClassCat"/>
AE>
AE>  <field name="classId" type="integer">
AE>    <sql name="Class_Id" type="integer" />
AE>  </field>
AE>  
AE>  <field name="applicationId type="integer">
AE>    <sql name="Application_Id" type="integer" />
AE>  </field>
AE>
AE>  <field name="className" type="string">
AE>    <sql name="Class_Name" type="varchar" />
AE>  </field>
AE>... 
AE></class>
AE>
AE>
AE>Here is the query
AE>
AE>"SELECT a.fundName, b.className FROM org.funds.Application a, 
AE>org.funds.Class b WHERE
AE>b.applicationId = a.applicationId"
AE>
AE>But not sure if I need to use depends in the mapping.
AE>
AE>In my code:
AE>OQLQuery query = dbase.getOQLQuery( strBuff );
AE>// strBuff is the query above
AE>
AE>QueryResults result = query.execute( true );
AE>Application apprst           = null;
AE>ClassCat classrst            = null;
AE>
AE>While( result.hasMore() == true )
AE>{
AE>    apprst = (Application)result.next();
AE>    
AE>
AE>    System.out.println( apprst.getFundName() );
AE>    *** Not sure how to get the class name from classcat ****  
AE>}

Eric, 

You should really take a look at the JDO examples in src/examples/jdo and
src/examples/myapp. Study and understand these examples before going any
further with your projet. It will help immensely. There are directions
to compiling and running them here:

    http://www.castor.org/examples.html

At first glance, you haven't established any relationship between
your objects. See the relationship between myapp.Product and
myapp.ProductDetail in the JDO examples. Also, your query is not going
to execute because it contains an explicit join. This is not necessary
when using OQL. Joins are handled by Castor based on the mapping of
your objects.

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

Reply via email to