ActiveJDBC Many2Many with child table in different schema from parent and join tables

279 views Asked by At

Say I have the one db schema named "action" that has the tables "actions" and "actionnotifications". Then I have another db schema named "notification" that has the table "notifications".

I am using ActiveJDBC to query the complex action object.

The Action class (which extends Model) has the following annotation: @Many2Many(other = Notification.class, join = "actionnotifications", sourceFKName = "actionId", targetFKName = "notificationId")

When I run the following code: List actions= Action.where("id = ?", actionId).include(Notification.class)

I get a MySQLSyntaxError exception saying that "Table 'action.notifications' doesn't exist". I have not seen anything in the ActiveJDBC documentation that talks about querying class relationships over different db schemas, does anyone have any experience accomplishing this task?

1

There are 1 answers

1
ipolevoy On

This is more of an issue of MySQL and not ActiveJDBC. Are you sure you can access tables from one schema while connected to another? The schema is really part of the MySQL JDBC URL, correct? If you can write a Java program that can access all your tables from different MySQL databases, that ActiveJDBC will be able to do that too.