Bugs item #544778, was opened at 2002-04-16 12:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=544778&group_id=22866

Category: JBossCMP
Group: CVS HEAD
>Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: Christian Riege (lqd)
Assigned to: Dain Sundstrom (dsundstrom)
Summary: generation of uni-directional CMR b0rked

Initial Comment:
it seems that when trying to use a UNIdirectional CMR
relationship JBossCMP insists on creating a foreign key
field on BOTH sides of the relationship. this should
not be; JBossCMP should ignore the side of the
relationship where no <cmr-field> element is defined.

snippet from ejb-jar.xml:

<ejb-relation>
 <ejb-relation-name>A-Uni-B</ejb-relation-name> 
 <ejb-relationship-role>
 <ejb-relationship-role-name>a-uni-b</ejb-relationship-role-name>
 <multiplicity>One</multiplicity>
 <relationship-role-source>
  <ejb-name>A</ejb-name>
 </relationship-role-source>
 <cmr-field>
  <cmr-field-name>fk_field</cmr-field-name>
 </cmr-field>
 </ejb-relationship-role>
 <ejb-relationship-role>
 <ejb-relationship-role-name>b-maps-a</ejb-relationship-role-name>
 <multiplicity>One</multiplicity>
 <relationship-role-source>
  <ejb-name>B</ejb-name>
 </relationship-role-source>
 </ejb-relationship-role>
</ejb-relation>

the tables created look like this:

table_a
 a_id
 a_fk_field

table_b
 b_id
 b_a_fk_field

the field 'b_a_fk_field' should *not* be generated in
my opinion as it is not declared in the deployment
descriptor; i.e. it has no matching <cmr-field> entry.
(jbosscmp-jdbc.xml is empty except for <defaults> element).

tested against both jboss 3.0rc1 as well as CVS HEAD.

----------------------------------------------------------------------

>Comment By: Dain Sundstrom (dsundstrom)
Date: 2002-04-17 12:10

Message:
Logged In: YES 
user_id=251431

When working with an existing DB schem, you need to specify 
an exact mapping in the jbosscmp-jdbc.xml file.

To tell JBossCMP to not create foreign keys for your entity 
simply add an empty <key-fields/> element to the A side of 
the relationship in your example below.

This is still not a bug, so please don't reopen.

----------------------------------------------------------------------

Comment By: Christian Riege (lqd)
Date: 2002-04-17 09:18

Message:
Logged In: YES 
user_id=176671

dain,

point taken. the problem is that i have to cope with an
existing DB schema and i am not able to convince the CMP
engine to deal with it.

my schema looks like this:

TABLE a (a_id int);
TABLE b (b_id int, related_a int);

I have two Entity Beans: ABean and BBean. BBean has a CMR
method setRelatedA. the mappings in ejb-jar.xml and
jbosscmp-jdbc.xml "seem" to be correct in my eyes. Despite
this, the CMP layer insists that table 'a' should contain a
field 'related_a'.

i've packaged this and attached it to this bug. i've also
taken the liberty to set this from REJECTED to OPEN again as
I think that it is a bug when adopting to an existing schema
instead of auto-creating the tables.

----------------------------------------------------------------------

Comment By: Christian Riege (lqd)
Date: 2002-04-17 09:17

Message:
Logged In: YES 
user_id=176671

dain,

point taken. the problem is that i have to cope with an
existing DB schema and i am not able to convince the CMP
engine to deal with it.

my schema looks like this:

TABLE a (a_id int);
TABLE b (b_id int, related_a int);

I have two Entity Beans: ABean and BBean. BBean has a CMR
method setRelatedA. the mappings in ejb-jar.xml and
jbosscmp-jdbc.xml "seem" to be correct in my eyes. Despite
this, the CMP layer insists that table 'a' should contain a
field 'related_a'.

i've packaged this and attached it to this bug. i've also
taken the liberty to set this from REJECTED to OPEN again as
I think that it is a bug when adopting to an existing schema
instead of auto-creating the tables.

----------------------------------------------------------------------

Comment By: Dain Sundstrom (dsundstrom)
Date: 2002-04-16 19:10

Message:
Logged In: YES 
user_id=251431

As you said this is an opinion thing.  I don't think it 
matters what the default is as long a it works and it can 
be overriden.

If there is community support for this change I'll make it.

I'm closing this, as it is not a bug.  Start a discussion 
on the jboss-user list or in the db forum if you really 
want change.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=544778&group_id=22866

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to