Hi folks,

I've just finished implementing a finder that can navigate across a many-to-many
join table, by embedding a SQL statement in the deployment descriptor. This was
based on Tim Drury's useful "Advanced Finder Methods" article on Orion Support (
http://orionsupport.com/articles/finders.html ). However I would much prefer to
have a direct collection-to-field mapping between the tables, where I could use
a get() method to obtain the collection of matching records rather than a finder.
I've had a look at the examples in the "Advanced Object-Relational Mapping" article
but am unsure whether they are useful, as they only appear to deal with one-to-many
mappings.

I was hoping someone might help me out by sending the appropriate part of the
deployment descriptor for the following example. It's of course possible that
this can't be done, in which case someone can break the bad news to me.

Say I have two tables "Movie" and "Actor" which both have EJ beans associated with
them. The primary key for both tables is a String in a column called "id". A
"Movie_Actor" join table gives a many-to-many mapping between the "Movie" and
"Actor" primary keys, which are in columns called "Movie_id" and "Actor_id". I
would like to set up a field "movies" in the "Actor" bean of type Collection, that
contains all of the movies associated with the current actor record.

What should the contents of <cmp-field-mapping name="movies">...</cmp-field-mapping>
be?

A secondary question, just in case anyone has run into this.

Will the contents of the "movies" field be updated if a new "Movie" record is added
and a new row is added to the "Movie_Actor" table mapping the current actor to the
new movie? Are there efficiency issues here? Are there any relevant best practices
I should be considering?

Thanks in advance.

-- 
Warren Hedley

Reply via email to