From terry-list@mienterprise.com :
The many-to-many implementation in CVS does seem to be
quite right. It
seems to ignore the @many-key and @sql-name elements
and just uses the
primary key name specified for each object.
I have a super class called AbstractDomain that defines
the OID for all
of my domain objects:
abstract public class AbstractDomain
{
...
/**
* @primary-key
*/
private Long OID;
...
}
I have a User and Role class that extend AbstractDomain
with a
many-to-many between them. For User, the association is:
public class User extends AbstractDomain
{
...
/**
* @many-table USER_ROLE
* @many-key USER_ID
* @sql-name ROLE_ID
* @field-type Role
* @lazy
*/
private Collection roles = new ArrayList();
...
}
Now the mapping.xml that is created is perfect but the
USER_ROLE table
in the DDL has two columns both with the name "OID":
CREATE TABLE USER_ROLE(
OID BIGINT NOT NULL,
OID BIGINT NOT NULL
, CONSTRAINT PK_USER_ROLE PRIMARY KEY (OID,OID)
)
;
Before I tried the CVS code, I was manually writing my
own USER_ROLE
statement as follows:
CREATE TABLE USER_ROLE
(
USER_ID BIGINT NOT NULL,
ROLE_ID BIGINT NOT NULL,
CONSTRAINT PK_USER_ROLE PRIMARY KEY (USER_ID,ROLE_ID)
)
Is my usage of many-to-many correct?