DeploymentException: Mappings were not provided
redbeard15 Oct 21, 2004 5:03 PMI'm running:
- JBoss 3.2.3
- Xdoclet 1.2.1
- MySQL 4.0.21
- Linux RedHat 9
I have what seems to be a rather classic data model:
Items:
- itemId
- price
- cost
- size
- productId
Products:
- productId
- name
- desc
- categoryId
Category:
- categoryId
- name
- desc
A category consists of a number of products, a product consists of a number of (individual) items. I also need composite keys on the DB tables (to guard against rows containing the same ID value). For 'Item' table, composite key is 'itemId-productId', for 'Products' table, key is 'productId-categoryId'.
I have CMP beans for each and I can get the relationship set (and working!) between Items and Products (But products with only 'productId' as PK).
It seems that I have to specify a CMP field (in my ItemBean) for the 'productId' in order to get the 'ItemPK' class generated with a composity key.
My (abbrieviated) Xdoclet tags for ItemBean look like:
/** Class tag
* @ejb.bean name="Item" type="CMP" view-type="local"
* schema="Item" cmp-version="2.x"
*/
public abstract class ItemBean implements EntityBean {
/**
* @ejb.pk-field
* @ejb.persistence column-name="itemId"
* @ejb.interface-method
* @ejb.transaction type="Supports"
*/
public abstract String getItemId( );
public abstract void setItemId( String ItemId );
/**
* @ejb.pk-field
* @ejb.persistence column-name="productId"
* @ejb.interface-method
* @ejb.transaction type="Supports"
*/
public abstract String getProductId( );
public abstract void setProductId( String ProductId );
/**
* @ejb.interface-method
* @ejb.relation name="product-items"
* role-name="item-belongs_to-product"
* cascade-delete="yes"
*
* @jboss.relation
* fk-column="productId"
* related-pk-field="productId"
* fk-contraint="true"
*
*/
public abstract ProductLocal getProduct( );
public abstract void setProduct( ProductLocal product );
.
}
My ProductBean class looks similar (with field names changed, of course). If I just specify a single '@ejb.pk-field' (on productId) in the ProductBean, I can get the Item/Product stuff work just fine. However, when I add the 'categoryId' CMP field (e.g., add another '@ejb.pk-field' for the 'categoryId') the deployment fails. It seems I need to add this 'ejb.pk-field' in the ProductBean to get a composite key generated in the ProductPK class (productId-categoryId composite key).
Here's what JBoss says when I try to deploy this set of beans:
2004-10-21 15:06:07,142 INFO [org.jboss.ejb.EjbModule] Deploying Item
2004-10-21 15:06:07,177 INFO [org.jboss.ejb.EjbModule] Deploying Product
2004-10-21 15:06:08,023 ERROR [org.jboss.ejb.EntityContainer] Starting failed
org.jboss.deployment.DeploymentException: Mappings were not provided for all fields: unmaped fields=[categoryId] in role=product-has-items
Wha? Why would the 'product-has-items' relationship care about the 'categoryId' field? Is there a simple solution?
Thanks,
R