views:

403

answers:

0

I'm new to Ibatis and have a question regarding the mapping of many-to-many relationships.

In my application's data model I have a many-to-many relationship between two of the entities, with the tables in the database looking like this:

CREATE TABLE A (
    id int PRIMARY KEY
)

CREATE TABLE B (
    id int PRIMARY KEY
)

CREATE TABLE ABMap (
    aid int FOREIGN KEY REFERENCES A(id),
    bid int FOREIGN KEY REFERENCES B(id)
)

In my code I then have classes that look like this:

public class A {
    int id,
    List<B> b;
}

public class B {
    int id;
}

My question is how should I go about handling insert's of the associations between A and B? Do I need to manually create a new SqlMap for the relationship table, or does Ibatis have any way of automatically handling the relationships?

For reference I'm using Ibatis 3 Beta 7.