Could you please try JBoss-3.2.0RC5 from CVS?
It should work. You can check a testcase in
org.jboss.test.cmp2.fkmapping package.

alex

Friday, April 04, 2003, 8:38:58 PM, you wrote:

BR> Hi All,

BR> I have created an Entity EJB that maps to a table with a compound PK
BR> (both columns are NOT NULL).  One of the columns of the PK, 
BR> "COMMUNITYID_FK" is a FK to another table representing the many side of 
BR> a 1-* relationship.

BR>  From sql file used to create table:
BR> -----------------------------------
BR> create table MEMBERS  (
BR>     MEMBERID             VARCHAR2(64)   not null,
BR>     COMMUNITYID_FK       VARCHAR2(64)   not null,
BR>     ISCREATOR            NUMBER(38)     not null,
BR>     DT_JOINED            DATE           not null,
BR>     DT_LASTVISITED       DATE           not null,
BR>     BGCOLOR              VARCHAR2(24),
BR>     FGCOLOR              VARCHAR2(24),
BR>     MESSAGEDISPLAY      NUMBER(38),
BR>     SUBSCRIBE           NUMBER(38),
BR>     NEWSLETTER          NUMBER(38),
BR>     GROUPEMAIL          NUMBER(38),
BR>     constraint PK_MEMBERS primary key (MEMBERID,COMMUNITYID_FK),
BR>     constraint FK_MEMBERS_COMMUNITY foreign key (COMMUNITYID_FK)
BR>           references COMMUNITY (COMMUNITYID)
BR>           on delete cascade
BR> );

BR> Using XDoclet, I can generate what appears to be the proper source and
BR> deployment descriptors...all of which deploy to JBoss-4alpha with no
BR> problem.

BR>  From my jbosscmp-jdbc.xml file:
BR> -------------------------------
BR> ...
BR>        <entity>
BR>           <ejb-name>Members</ejb-name>
BR>                  <datasource>java:/OracleDS</datasource>
BR>                  <datasource-mapping>Oracle9i</datasource-mapping>
BR>           <create-table>false</create-table>
BR>           <table-name>SYSTEM.MEMBERS</table-name>

BR>           <cmp-field>
BR>              <field-name>memberId</field-name>
BR>              <column-name>MEMBERID</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>communityIdFk</field-name>
BR>              <column-name>COMMUNITYID_FK</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>isCreator</field-name>
BR>              <column-name>ISCREATOR</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>dateJoined</field-name>
BR>              <column-name>DT_JOINED</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>dateLastVisited</field-name>
BR>              <column-name>DT_LASTVISITED</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>subscribe</field-name>
BR>              <column-name>SUBSCRIBE</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>newsletter</field-name>
BR>              <column-name>NEWSLETTER</column-name>

BR>           </cmp-field>
BR>           <cmp-field>
BR>              <field-name>groupEmail</field-name>
BR>              <column-name>GROUPEMAIL</column-name>

BR>           </cmp-field>

BR>           <!-- merge point: jbosscmp-jdbc-load-{0}.xml -->

BR>        </entity>
BR> ...

BR> ...

BR> <ejb-relation>
BR>        <ejb-relation-name>COMMUNITY-MEMBERS</ejb-relation-name>
BR>        <foreign-key-mapping/>

BR>        <ejb-relationship-role>
 
BR> <ejb-relationship-role-name>MEMBERS-has-COMMUNITY</ejb-relationship-role-name>
BR>            <fk-constraint>true</fk-constraint>
BR>                   <key-fields/>

BR>        </ejb-relationship-role>
BR>        <ejb-relationship-role>
 
BR> <ejb-relationship-role-name>COMMUNITY-has-MEMBERS</ejb-relationship-role-name>
BR>            <key-fields>
BR>               <key-field>
BR>                 <field-name>communityId</field-name>
BR>                 <column-name>COMMUNITYID_FK</column-name>
BR>               </key-field>
BR>            </key-fields>

BR>        </ejb-relationship-role>
BR> </ejb-relation>
BR> ...

BR> As you can see, the column "COMMUNITYID_FK" is the FK for the 
BR> relationship, as well as a persistent field...both CMP and CMR.

BR> The problem comes in when I try to create an instance of the EJB from a
BR> client app.  A SQLException is thrown, indicating you "can not insert
BR> NULL" into the column.

BR> The thread:
BR> http://www.mail-archive.com/[EMAIL PROTECTED]/msg03782.html 

BR> led me to believe this was fixed in 4-alpha.  Does anyone have it
BR> working yet?  Any advice...this driving me crazy.

BR> Thanks,
BR> -Billy



-------------------------------------------------------
This SF.net email is sponsored by: ValueWeb: 
Dedicated Hosting for just $79/mo with 500 GB of bandwidth! 
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to