Bugs item #1000758, was opened at 2004-07-30 18:25
Message generated for change (Comment added) made by loubyansky
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1000758&group_id=22866
Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Juan Martinez (juanmartinez)
Assigned to: Alexey Loubyansky (loubyansky)
Summary: auto-increment and CMR
Initial Comment:
Hi.
I've a couple of CMP beans which uses auto-increment
for their primary keys -- only important fields below.
ejb-jar.xml:
<prim-key-class>java.lang.Integer</prim-key-class>
<cmp-version>2.x</cmp-version>
<cmp-field >
<field-name>id</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
jbosscmp-jdbc.xml:
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>SERIAL</sql-type>
<auto-increment/>
</cmp-field>
<entity-command name="postgresql-fetch-seq">
using PostgreSQL 7.4.x for the backend.
The primary keys are incremented correctly from their
sequence.
But when I define a CMR between two beans a foreign
key constaint between the tables aren't created;
preferredrelationmapping is foreign-key.
<problem>
Instead a sequence is generated for the column; f.ex:
"not null default nextval('public.b1_b2_seq'::text)"
</problem>
(\d tablename in PostgreSQL's PSQL)
I've tried to define with/without ejb-relation tags in the
jbosscmp-jdbc.xml file.
F.ex. in ejb-jar.xml:
<ejb-relation >
<ejb-relation-name>b1-b2</ejb-relation-name>
<ejb-relationship-role >
<ejb-relationship-role-name>b1-has-b2</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source >
<ejb-name>b1</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>b2ref</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role >
<ejb-relationship-role-name>b2-belongs-to-b1</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<cascade-delete/>
<relationship-role-source >
<ejb-name>b2</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
But the problem are for all kinds of relationsships:
one-one, one-many and many-many.
I havn't tried with any other database since we only use
PostgreSQL, sorry.
Using both Branch_3_2 and HEAD.
Hope this gives you an idea -- otherwise let me know.
Juan
----------------------------------------------------------------------
>Comment By: Alexey Loubyansky (loubyansky)
Date: 2004-08-10 13:24
Message:
Logged In: YES
user_id=543482
You can't have key-fields on the many side with foreign key
mapping.
If the problem SERIAL foreign key, you know how to fix it.
Am I missing something?
----------------------------------------------------------------------
Comment By: Juan Martinez (juanmartinez)
Date: 2004-08-10 12:28
Message:
Logged In: YES
user_id=870070
Yes - the foreign key column type was SERIAL.
When I use the jdbc-type/sql-type I can change the column type to
INTEGER as you specified in your comment. But not the many
relationsships:
Role: whatever-to-whatever with multiplicity many using foreign-key
mapping is not allowed to have key-fields.
When I remove the key-fields section the deployment works but I don't
have a bi-directional relationsship anymore.
I havn't been able to get the deployment to work since there are many
relationsships that contain a many multiplicity, so I can't say if my
testcases works in the one multiplicity case, sorry.
Let me know if I can provide you with more information.
Juan
----------------------------------------------------------------------
Comment By: Alexey Loubyansky (loubyansky)
Date: 2004-08-08 17:23
Message:
Logged In: YES
user_id=543482
You mean foreign key column type was SERIAL? This can be
configured
<ejb-relationship-role>
<ejb-relationship-role-name>B-has-A</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>id</field-name>
<column-name>b1_id</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>INTEGER</sql-type>
</key-field>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1000758&group_id=22866
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development