I've also considered implementing two 1:N relations, instead of spinning my wheels on getting bidirectional M:N to work.
Today, i'm not having much more luck than yesterday. Either xdoclet won't generate the relationship secion of ejb-jar.xml, or when it does, it's incomplete or jboss doesn't like what it's trying to parse.
You wouldn't have a bit of working source to share with me/us, would you?
Barring that, i may just end up humbly asking the folks on this list to help me do a bit of distributed debugging on my code.
Thanks much,
Rick
[EMAIL PROTECTED] wrote:
http://www.jboss.org/thread.jsp?forum=47&thread=41050&message=3810264 I tried it also and finally got it working, but I won't use it anymore. Too much hassle. My "link table" also has other attributes. Instead I use two 1:N relations. regards, Jeroen.
Rick,
When I use CMS, the roles must be pre-configured in web.xml, I usually need not delete the roles in database as long as they are setup and If I do so, it will cause problem. There is no requirement for me that given a role, list all the users related. Using such a query will results an extremely large result set in an internet application. You can use bi-directional relationship between User and Role, nothing wrong about that if that makes life easier. From my understanding, ejb deploy descriptor can be categorized into 4 parts: entity declaration, relationship declaration;
entity mapping declaration, relationship mapping declaration.
The former should be in standrad dd while the later goes in vender specific dds. In my application, I have User and Role as entity bean. UserRole is the result of n-m relationship mapping between the two ebtity beans. As for cacade delete, it is just that JBossCMP cann't do it for you in n-m relationship. I met many limitations using CMR. I have to work around by manual coding. I guess that is not unusual.
If your ejbdoclet task declaration in your build.xml is properly setup(including all the dependent class lib), another cause of not generating the dd may be the package name in the class file is not compatible with its location. Maybe you can have a check of both.
Hope it helps,
Guo --- "R. P. Ruiz" <[EMAIL PROTECTED]> �����ģ�> Guo & all,
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 u
ser. 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
