hi scott,

there's a problem with your mapping, i think. you mixed the mapping for the
m:n-relationship.

for m:n relationships you have two mapping-possibilities:

1.) map it with the indirection table
in your case User has a realtionship to Group (no need for class-definition
of  Role)

         <collection-descriptor
             name="groups"
             element-class-ref="com.stmpjmpr.system.Group"
             auto-retrieve="true"
             auto-update="true"
             indirection-table="roles"
         >

and back from Group to User

         <collection-descriptor
             name="users"
             element-class-ref="com.stmpjmpr.system.User"
             auto-retrieve="true"
             auto-update="true"
             indirection-table="roles"
         >

2.) map the relationship as two separate 1:n relationships from User to Role
and from Group to Role:

        User to Role:

         <collection-descriptor name="roles"
            element-class-ref="com.stmpjmpr.system.Role"
            <inverse-foreignkey field-id-ref="1"/>
         </collection-descriptor>

        Group to Role:

         <collection-descriptor name="roles"
            element-class-ref="com.stmpjmpr.system.Role"
            <inverse-foreignkey field-id-ref="2"/>
         </collection-descriptor>

for further info please consult tutorial3.html dealing with  advanced
mapping.

hth
jakob

----- Original Message -----
From: "Scott W. Hill" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Friday, October 25, 2002 1:47 AM
Subject: Re: Problem with M:N association


> Yeah, looks like the SQL should be:
>
> SELECT A0.name,A0.description,A0.id FROM groups A0 INNER JOIN roles A1
> ON A0.id=A1.group_id WHERE (A1.user_id =  ? )
>
> instead of:
>
> SELECT A0.name,A0.description,A0.id FROM groups A0,roles INNER JOIN
> roles A1,roles ON A0.id=A1.group_id WHERE (roles.user_id =  ? ) AND
> roles.group_id = A0.id
>
> Anyone have any ideas on a fix/workaround?
>
> On Thursday, October 24, 2002, at 02:59  PM, Scott W.Hill wrote:
>
> > Well, the error is different now. It looks like it's trying to inner
> > join on roles twice if I'm reading it right.
>
> --Scott
>
>
> --
> To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to