The DAS does not directly support M:N relationships so although you can
achieve this using two 1:m relationships. You just need to model the
join table.
Thanks,
--Kevin
Sam Su wrote:
/**************************XSD***************************/
<xsd:complexType name="User">
<xsd:sequence>
<xsd:element name="userId" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="available" type="xsd:string"/>
<xsd:element name="roles" type="this:Role"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Role">
<xsd:sequence>
<xsd:element name="roleId" type="xsd:string"/>
<xsd:element name="description" type="xsd:string"/>
<xsd:element name="users" type="this:User"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
/************************TABLE SCRIPT**************************/
/*==============================================================*/
/* Table: CCP_USER
/*==============================================================*/
create table CCP_USER (
USER_ID VARCHAR2(100) not null,
PASSWORD VARCHAR2(100) not null,
NAME VARCHAR2(100) not null,
AVAILABLE CHAR(1) not null,
constraint PK_CCP_USER primary key (USER_ID)
);
/*==============================================================*/
/* Table: CCP_ROLE */
/*==============================================================*/
create table CCP_ROLE (
ROLE_ID VARCHAR2(100) not null,
DESCRIPTION VARCHAR2(1000),
constraint PK_CCP_ROLE primary key (ROLE_ID)
);
/*==============================================================*/
/* Table: CCP_USER_ROLE */
/*==============================================================*/
create table CCP_USER_ROLE (
USER_ID VARCHAR2(100) not null,
ROLE_ID VARCHAR2(100) not null,
constraint PK_CCP_USER_ROLE primary key (USER_ID, ROLE_ID)
);
There is a many to many relationship between CCP_USER and CCP_ROLE, I
want
to get a User dataojbect and its roles list is also retrieved from
database , how to do by using Tuscany DAS?
/*********** i want to use following code to get role list of each user
**************/
List users=root.getList("User");
System.out.println(users.size());
for(int i=0;i<users.size();i++){
User obj=(User)users.get(i);
System.out.println(obj.getUserId());
List roles=obj.getRoles();
System.out.println(roles.size());
for(int j=0;j<roles.size();j++)
System.out.println(((Role)roles.get(j)).getRoleId());
}
Any idea or experience? thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]