This question is NOT related to Bruce's article - it connect to my own simple test
setup. I feel it's an important question. It has been posted before, but without any
replies. Is the question too trivial?
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 now see that the "setMovies"
method is 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