Hi!
I am trying to model a situation where I have a table "movies" and a table "people". I want to store movie actors, as well as movie directors. My idea was therefore to create to assotiation tables between movies and people. So I created the schema like this:
"CREATE TABLE movies (" +
"id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"title TEXT, " +
"year INTEGER " +
")"
"CREATE TABLE people (" +
"id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"name TEXT " +
")"
"CREATE TABLE movies_actors (\n" +
"movie_id INTEGER NOT NULL REFERENCES movies(id), " +
"person_id INTEGER NOT NULL REFERENCES people(id), " +
"PRIMARY KEY (movie_id, person_id)\n" +
")"
"CREATE TABLE movies_directors (\n" +
"movie_id INTEGER NOT NULL REFERENCES movies(id), " +
"person_id INTEGER NOT NULL REFERENCES people(id), " +
"PRIMARY KEY (movie_id, person_id)\n" +
")"
And created the 4 corresponding models:
public class Movie extends Model {}
public class Person extends Model {}
@Table("movies_actors")
public class MovieActors extends Model {}
@Table("movies_directors")
public class MovieDirectors extends Model {}
However, ActiveJDBC does not seem to recognize the models for the associations. Indeed, in the samples I cannot find how to specify which of the two associations I want to use when retrieving persons (actors) related to a movie. Thus, when I execute:
List<Person> actors = movie.getAll(Person.class);
I get "NotAssociatedException: No association from table 'movies' to table 'people'"
Is it possible to achieve what I am trying in ActiveJDBC?
Sorry if I am making some basic mistake, I just started with ActiveJDBC a couple hours ago! (it seems awesome, by the way, thanks for it!)
Regards.