Thanks for responding so quickly, i was beginning to feel a bit adrift.
Here's why i want to use what i understand is a a bi-directional relationship: just as i want to be able to retrieve all roles that a user has, i also want to retrieve all users who have a role of type 'appOneUser' for instance. As i understand it, i can't currently do this w/o declaring a cmr. This type of query will prove invaluable once i'm using the User/UserRole/Role entities to manage accounts for multiple applications deployed to different container contexts, each w/ many possible roles.
The former (get a user's roles) i can already do w/o having to declare a cmr, as all i have to do is call a finder method on the UserRole entity to get all roles of type 'foo' and who's userid is 'x'.
The later (get a role's users) is a bit more problematic, and i was hoping that declaring a bidirectional relationship would allow me to write a query that traverses the User/UserRole/Role tables w/o having to resort to implementing a BMP entity using hand-rolled SQL code. Any thoughts on this?
As far as cascade deletes are concerned, i can live w/o the container automating them for me, i can just delete the roles a given user has as i delete the user. Just a bit more code for me, and it seems much more manageable than finding 'all users that have a role of type foo' since that requires a join on tables.
I've already tried to use what you've given me, and can't seem to get xdoclet to generate anyting in the ejb-jar.xml file. That's nothing new this week though, as i've encountered a number of examples online that xdoclet (for me) doesn't generate any relationship entries for. I'll have to try it again tomorrow w/ a clearer head.
From what i've described, can you tell me if i've at least understood the concept of a bi-directional many-to-many relationship?
I'll let you know how it goes for me once i give your source another go tomorrow.
Thanks,
Rick
guo yingshou wrote:
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
