Skip Headers

# Many-to-Many Join Tables and Direct Collection Tables

Previous

Next

By default, TopLink assumes that many-to-many and direct collection tables are on the same database as the source object. If they are on a different database, then you must configure the mapping's session name using `ManyToManyMapping` or `DirectCollectionMapping` method `setSessionName` as Example: Using Mapping setSessionName in a Descriptor Amendment Method illustrates.Note that a many-to-many join table must still reside on the same database as the target object.

Using Mapping setSessionName in a Descriptor Amendment Method

              public void addToDescriptor(ClassDescriptor descriptor) {
        descriptor.getMappingForAttributeName("projects").setSessionName("branch-database");
    }

To work around this problem for data-level queries, use the `DatabaseQuery` method `setSessionName`.