Thanks Adam,
I tried *exactly* what you suggested below, but I still get the following
error when using weblogic's ejbc with ant:
======== Start ERROR ============
ejb_compile:
[java] ERROR: Error from ejbc: [EJB:011017]Error while reading
'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was
:
[java]
[java] Role 'one-postalDepot-has-many-packages' of relationship
'package-postalDepot' contains an invalid key-colum
n value of 'POSTAL_DEPOT_KEY'. The key-column must specify a primary key
column in the related bean. However, there is n
o primary key column named 'POSTAL_DEPOT_KEY' defined in the related bean
'PostalPackage' or else 'POSTAL_DEPOT_KEY' is
not being recognized due to case mismatch.
[java] .
======== End ERROR ============
To me it seems to be saying that it is expecting to match the key-column
value to the primary key of PostalPackageBean, rather than PostalDepot. If
I swap the foreign-key-column and key-column declarations around then I get
the following error:
======== Start ERROR ============
ejb_compile:
[java] ERROR: Error from ejbc: [EJB:011017]Error while reading
'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was
:
[java]
[java] Role 'one-postalDepot-has-many-packages' of relationship
'package-postalDepot' contains an invalid key-colum
n value of 'POSTAL_DEPOT_ID'. The key-column must specify a primary key
column in the related bean. However, there is no
primary key column named 'POSTAL_DEPOT_ID' defined in the related bean
'PostalPackage' or else 'POSTAL_DEPOT_ID' is not
being recognized due to case mismatch.
[java] .
======== End ERROR ============
It is really annoying me that I cannot get Xdoclet to generate the correct
descriptor. I've achieved something similar using a bi-directional
relationship but not exposing the get/setPostalPackages() on the
PostalDepotBean and it works fine. But it makes me feel unclean to leave
such a confusing hack in the code (Why specify bi-directional if I'm hiding
one side??).
I've wasted enough time on this already so I'm afraid that these abberations
will have to stay in my code - unless somebody comes to my rescue!
Thanks,
Simon.
-----Original Message-----
From: Adam Houghton [mailto:[EMAIL PROTECTED]
Sent: 05 November 2003 21:20
To: [EMAIL PROTECTED]
Subject: RE: [Xdoclet-user] Many to 1 Unidirection Relationship
I think the problem is with your key-column field. This should be assigned
to the primary key column of your PostalDepot bean, not your PostalPackage
bean. So, for this sample data schema (* = primary key):
postal_depot
-------------
postal_depot_id int *
name varchar
description varchar
postal_package
--------------
postal_package_id int *
name varchar
description varchar
postal_depot_key int
you'd have the following XDoclet tag in PostalPackage:
/**
* @return the postal depot for this package
* @ejb:interface-method view-type="local"
* @ejb:relation
* name="package-postalDepot"
* role-name="one-package-belongs-to-one-postalDepot "
* target-role-name="one-postalDepot-has-many-packages"
* target-ejb="PostalDepot"
* target-multiple="yes"
*
* @weblogic:column-map
* foreign-key-column="postal_depot_id"
* key-column="postal_depot_key"
*/
public abstract PostalDepotLocal getPostalDepot();
/**
* @param postalDepot the postal depot for this package
* @ejb:interface-method view-type="local"
*/
public abstract void setPostalDepot(PostalDepotLocal postalDepot);
The format of the weblogic-cmp-rdbms-jar.xml file looks correct. The
ejb-jar.xml file still has all the standard relationship elements with the
multiplicity defined. WebLogic uses weblogic-cmp-rdbms-jar.xml only to know
what database columns to map to the relationship (which isn't defined in the
EJB spec). WebLogic can tie that info with ejb-jar.xml because the
relationship names are the same.
- Adam
-------------------------------------------------------
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