#62 Ability to use {0}-par. in ejb:relation

open
nobody
ejbdoclet (28)
5
2002-06-20
2002-06-20
Anonymous
No

I have a cmp bean SuperBean, which is superclass to a
number of other beans, FirstBean, SecondBean and
ThirdBean. Now, all three sub-beans are identical to
the super-bean apart from the name itself - they have
exactly the same persistent and relational fields.

The problem is that the relational field (one-to-many,
unidirectional) cannot be inherited, or more precisely
the xdoclet tags

@ejb:relation name
relation-name
target-relation-name
@jboss:target-relation fk-column

since, if I define them in SuperBean, the relations in
First-, Second- and ThirdBean will all be called the
same thing ("superbean-somebean"). This forces me to
put the relational fields in the sub-beans, so that I
can specify relation names etc. directly
("firstbean-somebean" and so on). But then I will also
have to put the ejbPostCreate() method in the
sub-beans, because I cannot call the relational field
from the ejbPostCreate() in SuperBean since there is no
such fields in it.

This leads to "copy-paste-inheritance", identical code
in several places. A solution would be to enable the
use of ejb-name parameters inside the ejb:relation tag.
Then I could name the relations "{0}-somebean" in the
superclass, and similarly for the column-names. Doing
this in XDoclet 1.1.2 generates
<ejb-relationship-role-name>{0}-somebean<ejb-.../>.
This would also eliminate the need for moving the
ejbPostCreate() method outside SuperBean.

Discussion