This one time, at band camp, Peter Jeszenszky said:

PJ>Hello,
PJ>
PJ>I have the following PostgreSQL tables:
PJ>
PJ>     CREATE TABLE articles(
PJ>             article_id      INTEGER PRIMARY KEY,
PJ>             title   VARCHAR(40)
PJ>     ) ;
PJ>
PJ>     CREATE TABLE keywords(
PJ>             article_id      INTEGER REFERENCES articles,
PJ>             keyword VARCHAR(20),
PJ>             PRIMARY KEY(article_id, keyword)
PJ>     ) ;
PJ>
PJ>I also have the following Java object:
PJ>
PJ>     public class Article {
PJ>             protected int   id;
PJ>             protected String        title;
PJ>             protected java.util.Vector      keywords;
PJ>
PJ>             /* ... The appropriate get/set methods also provided */
PJ>     }
PJ>
PJ>The keywords Vector data member of the Article object should hold all the
PJ>keywords that belongs to the article having the the same article_id in the
PJ>table keywords.
PJ>
PJ>How to bind the keyword vector in the object using the <sql> element to get
PJ>the correct behavior?
PJ>
PJ>     <class name="Article" identity="id">
PJ>             <map-to table="articles"/>
PJ>
PJ>             <field name="id" type="integer">
PJ>                     <sql name="id" type="integer"/>
PJ>             </field>
PJ>
PJ>             <field name="title" type="string">
PJ>                     <sql name="title" type="char"/>
PJ>             </field>
PJ>
PJ>             <field name="keywords" type="string" collection="vector">
PJ>                     <!-- WHAT COMES HERE??? -->
PJ>             </field>
PJ>     </field>

Peter,

First of all, Castor does not support a collection of primitive
objects. It will currently only handle a collection of complex objects
(i.e. objects from your object model). Based on what you've decribed,
the one thing that is missing is the Keyword object. Given a Keyword
object, the keywords <field> element of the Article <class> element
should look like the following:

    <field name="keywords" type="Keyword" collection="vector">
        <sql many-key="article_id" />
    </field>

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