I did in JBuilder before, I don't have to know much about it, because JBuilder is so easy to use and has a clear interface to
define everything, I don't have to know what is going on below the scene.
However, when using WSAD, I lost myself, when doing the same thing, creating relationship between CMPs, failed always.
Let me explain:
I got two tables: Catalog and Module, the relationship between them is M:1.
The database structure is quite simple too, just for
test purpose, list below:
Catalog:
id:integer
name:varchar(20)
moduleId:integer
Module:
id:integer
name:varchar(20)
It's so simple that we can see the column "muduleId" is a foreign key of table "Module". quite simple.
Useing botton-up model, I got two CMPs, no problem. and then when I was trying to define a relationship between them, the
WSAD generated such deployment descriptor:
<?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" <br /> "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>EpcEjb</display-name>
<enterprise-beans>
<entity id="ContainerManagedEntity_1062039321713">
<ejb-name>Catalog</ejb-name>
<home>au.com.ids.epc.ejb.CatalogHome</home>
<remote>au.com.ids.epc.ejb.Catalog</remote>
<local-home>au.com.ids.epc.ejb.CatalogLocalHome</local-home>
<local>au.com.ids.epc.ejb.CatalogLocal</local>
<ejb-class>au.com.ids.epc.ejb.CatalogBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>au.com.ids.epc.ejb.CatalogKey</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Catalog</abstract-schema-name>
<cmp-field id="CMPAttribute_1062046705047">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1062046705057">
<field-name>name</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1062046705077">
<field-name>moduleid</field-name>
</cmp-field>
<ejb-local-ref id="EJBLocalRef_1062137964614">
<ejb-ref-name>ejb/Module</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>au.com.ids.epc.ejb.ModuleLocalHome</local-home>
<local>au.com.ids.epc.ejb.ModuleLocal</local>
<ejb-link>Module</ejb-link>
</ejb-local-ref>
</entity>
<entity id="ContainerManagedEntity_1062046625463">
<ejb-name>Module</ejb-name>
<home>au.com.ids.epc.ejb.ModuleHome</home>
<remote>au.com.ids.epc.ejb.Module</remote>
<local-home>au.com.ids.epc.ejb.ModuleLocalHome</local-home>
<local>au.com.ids.epc.ejb.ModuleLocal</local>
<ejb-class>au.com.ids.epc.ejb.ModuleBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>au.com.ids.epc.ejb.ModuleKey</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Module</abstract-schema-name>
<cmp-field id="CMPAttribute_1062046705087">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1062046705088">
<field-name>name</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1062046705089">
<field-name>comment</field-name>
</cmp-field>
<ejb-local-ref id="EJBLocalRef_1062137964674">
<ejb-ref-name>ejb/Catalog</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>au.com.ids.epc.ejb.CatalogLocalHome</local-home>
<local>au.com.ids.epc.ejb.CatalogLocal</local>
<ejb-link>Catalog</ejb-link>
</ejb-local-ref>
</entity>
</enterprise-beans>
<relationships>
<ejb-relation>
<description></description>
<ejb-relation-name>Catalog-Module</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>module</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source>
<ejb-name>Catalog</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>module</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>catalog</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Module</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>catalogs</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
</ejb-jar>
I think it's right, because it's the same from what I seen in "Mastering
EJB 2.0". but the WSAD won't compile, suggested me:
the catalogs role is not mapped
the module role is not mapped
Oh, with such simple error message, how can I know what it really means?
and I do comfuse because I don't with such descriptor, how can the container know I have defined relationship between this two tables, and what condition to use when join these two tables.
Confused. help me. SOS!