Check the castor examples. you need to remove the sql element from the
collection mapping on hansen.playground.Media.
you can also add a method to the Media class setMoves(Collection c),
then you can use lazy loading too :)

cheers
db

--- Keld Helbig Hansen <[EMAIL PROTECTED]> wrote:
> I've got a very simple setup (only for testing Castor-JDO) with two
> objects "media" and "movie".   
> "media" is implemented as a table with two rows having the values
> "DVD" and "VHS".
> "movie" represents a movie in either DVD or VHS format.  
> I've got a one-to-many relation from object "media" to object
> "movie":
> 
>   <class name="hansen.playground.Media" identity="id">
>     <map-to table="media" />
>     <field name="id" type="integer">
>       <sql name="id" type="integer"/>
>     </field>
>     <field name="type" type="string">
>       <sql name="type" type="char" />
>     </field>
>     <field name="movies" type="hansen.playground.Movie"
> collection="arraylist">
>       <sql many-key="id_media" />
>     </field>
>   </class>
> 
>   <class name="hansen.playground.Movie" identity="id">
>     <map-to table="movie" />
>     <field name="id" type="integer">
>       <sql name="id" type="integer"/>
>     </field>
>     <field name="media" type="hansen.playground.Media"
> required="true">
>       <sql name="id_media" />
>     </field>
> . . . (more fields here)
>   </class>
> 
> In the Media class I have these methods:
> 
>   public void setMovies(ArrayList movies) { this.movies = movies; }
> 
>   public void addMovie(Movie movie) {
>     movies.add(movie);
>   }  
>  
> If I load say the "DVD" media object from the database (by a query) I
> can see that the "addMovie" method is called for every movie in DVD
> format.
> 
> If I remove this method and repeat the exercise I can see that the
> "setMovies" method is now called (once).
> 
> I understand that "setMovies" can be called since it's a normal
> "setter"-method for the "movies" property. 
> But why is "addMovie" called at all?
> 
> Is there something special about the name "addMovie" since it's
> called?   
>  
> Why has "addMovie" priority over "setMovies"?
> 
> Thanx for your help!
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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

Reply via email to