Attached is my working copies of what you want with a little difference. I use uni-directional relationship from user to role. I wonder why you want a bi-directional one. Besides, you cann't do cascade delete unless the other side of the relationship has a multiplicity of one. That is to say, in your case of n-m relationship, you cann't do this. You might need to adust your requirement a bit. Also I use value object generate by XDoclet, if you don't use it, just comment out the value object tag both at class level and method level.
Hope it helps. guo --- "R. P. Ruiz" <[EMAIL PROTECTED]> 的正文:> Greetings! > > After much tail chaising with JBoss 3.2.x, > Many-to-Many CMR, & XDoclet > v1.2b3 (much searching, reading, trial-and-error, > and gnashing of > teeth), i've decided that i'm in serious need of > guidance... > > I'm trying to implement what i believe is a > bidirectional many-to-many > cmr cmp relationship between two entities: > > 1) UserBean and > 2) RoleBean > > Their relationship can be described as: "any/many > users can have > any/many roles". > > I've implemented the 2 entities listed above, in > addition to a UserRole > entity which functions as a xwalk table between User > and Role. Thus far, > i've been happily using them as a JBoss JAAS > authentication dataSource > for the last month, w/o declaring any kind of cmr > relationship between > them. What i want to do now is declare > relationships between entities > so that: > > 1) when i find a user, i can get a collection of > their roles as an > attribute of the user object (instead of a separate > lookup in the role > entity, which i can currently do), > > 2) when i find a role, i can get a collection of the > users who have this > role, expressed as an attribute of the roles entity > (i can't do this > with my current entity implementations) > > 3) when i delete a user, i want their delete to > cascade and remove all > of their roles, but not vice versa (removing a role > does not delete the > user(s) associated with it) > > Does anybody have a working example of a > bidirectional Many-to-Many > relationship that works with JBoss 3.2.1 that they > would care to share > with me? > > Even if you don't have a working example, feel free > to let me know if > i'm not describing my problem very well or am not > using the correct > terminology. > > Thanks, > > Rick > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: ApacheCon 2003, > 16-19 November in Las Vegas. Learn firsthand the > latest > developments in Apache, PHP, Perl, XML, Java, MySQL, > WebDAV, and more! http://www.apachecon.com/ > _______________________________________________ > xdoclet-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/xdoclet-user __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
UserBean.java
Description: UserBean.java
RoleBean.java
Description: RoleBean.java
