Re: [JBoss-user] [newbie] creating multiple beans at once

2004-02-06 Thread Stefan Schuster
Hi,

if you are using XDoclet, you probably forgot
the @ejb.relation target-multiple=yes parameter.
(Can also be multiple=yes, depends on your setup)

Stefan

> Hi,
>
> I ran into a strange problem (for me). I have a few CMP beans that map
> to a postgresql database. When I run the following code, only the first
> entry is added correctly to the table. The others do have empty values
> on 'fk_kv' field in database.
>
> Shortened code (without exception handling etc):
> 
>
> Kv kv = kvlh.findByKVID(kvid);
> Teilnehmer t = tlh.findByPrimaryKey(new Integer(7));
> Kommission k = klh.create(kv, t);
>
> Kv kv = kvlh.findByKVID(kvid);
> Teilnehmer t = tlh.findByPrimaryKey(new Integer(7));
> Kommission k = klh.create(kv, t);
>
> Kv, Teilnehmer and Kommission are local interfaces (implementing
> EJBLocalObject).
>
>
> JBoss-log:
> --
>
> First execution:
> DEBUG [TeilnehmerBean] Executing SQL: SELECT pkey FROM kommission WHERE
> (fk_teilnehmer=?)
> DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET
> fk_teilnehmer=?, fk_kv=? WHERE pkey=?
> DEBUG [KommissionBean] Rows affected = 1
>
> Second execution:
> DEBUG [TeilnehmerBean] Executing SQL: SELECT pkey FROM kommission WHERE
> (fk_teilnehmer=?)
> DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET
> fk_teilnehmer=?, fk_kv=? WHERE pkey=?
> DEBUG [KommissionBean] Rows affected = 1
> DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET fk_kv=?
> WHERE pkey=?
> DEBUG [KommissionBean] Rows affected = 1
>
> Why does JBoss update the entry once more? After the first update all
> should be correct, shouldn't it?
>
> The 'kommission' table:
> ---
> CREATE TABLE kommission (
>   pkey int4 DEFAULT nextval('"kommission_pkey_seq"'::text) NOT NULL,
>   fk_teilnehmer int4,
>   fk_kv int4,
> ...some constraints...
> }
>
> In my deployment descriptors I have no cmp setters/getters for this
> table, but ejb-relationship-roles.
>
> Thanks in advance.
>
> Steffen Gransow
>
>
>
>
> ---
> The SF.Net email is sponsored by EclipseCon 2004
> Premiere Conference on Open Tools Development and Integration
> See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
> http://www.eclipsecon.org/osdn
> ___
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>



---
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [newbie] creating multiple beans at once

2004-02-05 Thread Steffen Gransow
Hi,

I ran into a strange problem (for me). I have a few CMP beans that map
to a postgresql database. When I run the following code, only the first
entry is added correctly to the table. The others do have empty values
on 'fk_kv' field in database.

Shortened code (without exception handling etc):


Kv kv = kvlh.findByKVID(kvid);
Teilnehmer t = tlh.findByPrimaryKey(new Integer(7));
Kommission k = klh.create(kv, t);

Kv kv = kvlh.findByKVID(kvid);
Teilnehmer t = tlh.findByPrimaryKey(new Integer(7));
Kommission k = klh.create(kv, t);

Kv, Teilnehmer and Kommission are local interfaces (implementing
EJBLocalObject).


JBoss-log:
--

First execution:
DEBUG [TeilnehmerBean] Executing SQL: SELECT pkey FROM kommission WHERE
(fk_teilnehmer=?)
DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET
fk_teilnehmer=?, fk_kv=? WHERE pkey=?
DEBUG [KommissionBean] Rows affected = 1

Second execution:
DEBUG [TeilnehmerBean] Executing SQL: SELECT pkey FROM kommission WHERE
(fk_teilnehmer=?)
DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET
fk_teilnehmer=?, fk_kv=? WHERE pkey=?
DEBUG [KommissionBean] Rows affected = 1
DEBUG [KommissionBean] Executing SQL: UPDATE kommission SET fk_kv=?
WHERE pkey=?
DEBUG [KommissionBean] Rows affected = 1

Why does JBoss update the entry once more? After the first update all
should be correct, shouldn't it?

The 'kommission' table:
---
CREATE TABLE kommission (
  pkey int4 DEFAULT nextval('"kommission_pkey_seq"'::text) NOT NULL, 
  fk_teilnehmer int4, 
  fk_kv int4,
...some constraints...
}

In my deployment descriptors I have no cmp setters/getters for this
table, but ejb-relationship-roles.

Thanks in advance.

Steffen Gransow




---
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user