Hi Maxime,

You might want to run this by the JBoss list as well, as it sounds like
JB is incorrectly building the SQL insert statement. I guess that it's
getting confused since you have the foreign key field mapped as a CMP
field *and* a CMR field. I do this in my beans, and it works fine.
However, I'm using WebLogic.

To test this, simply remove the CMP field mapping. If you still need a
"getForignKeyId()" accessor, you can do it like this:

  public Integer getPersonId()
  {
    PersonLocal person = getPerson();
    return person.getId();
  }

Of course, your bean isn't called Person, but I must confess that I
don't know what numetbper means -- or even what language. I assumed
French, but babelfish isn't liking it in any language I try. :) In any
case, mark the above method as @ejb.interface-method but don't map it to
a database column. It sucks that you'll have to load the related bean
just to get its ID when you already have it. C'est la vie.

Good luck!

David Harkness
Sony Pictures Digital Networks
(310) 482-4756


-----Original Message-----
From: Maxime Chevalier [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 25, 2003 3:46 AM
To: [EMAIL PROTECTED]
Subject: RE: [Xdoclet-user] JBoss + CMR


First of all: Thank you for the answers

Adam Levine wrote:
>I'm guessing you're using JBoss.
>
>If your tables already exist, it shouldn't be attempting to create 
>them. If your tables already exist as shown, they should be fine (with 
>the fk column in the phone table).

>What is the exact error message you're receiving? I know Jboss will let

>you know that the table already exists, and that it won't create it -- 
>but that's informational only, and not an error.

You guess fine: I use JBoss 3.0.6

The error is the following:
12:13:13,502 ERROR [STDERR] javax.ejb.CreateException: Could not create
entity:java.sql.SQLException: ORA-00957: Column name duplicate

I manage to see the SQL code sent to the database:
INSERT INTO PERSONNE (NUMPER, NOMPER, PRENOMPER, ADRPER, VILLEPER,
PAYSPER, TELPER, FAXPER, EMAILPER, PORTPER, TYPPER, TITREPER, DESCPER,
ETATPER, NUMETBPER, NUMSOCPER, CIVILPER, INITUTIMODPER, DATEMODPER,
MAILPER, THMAILPER, NUMETBPER) VALUES (...)

We can see that NUMETBPER appears 2 times. One for the setNumetbper (the
FK) and I guess JBoss adds one for the CMR field. How can I avoid this ?
I try to remove the persistence tag on set/get-Numetbper but it
generates errors...



Harkness, David wrote:
>I use setLocalUserId in ejbPostCreate to hook up the relation. This is 
>a
bi-directional
>relation (all relations in my app are a mix of bi/uni-directional 1:N),

>and
in all cases
>I'm
>setting the "parent" (1) bean in the "children" (N) beans. Are you 
>setting
your CMR fields
>in ejbCreate rather than ejbPostCreate?

According to your advice, I try to use the setNumetbper in the
ejbPostCreate but get still the same error of Column name duplicate...

I'm a bit lost :(
Must I change all my model ? (but my tables are imposed)
Thank you.





-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01
/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to