In the ejbRemove method for your project ejb, are you calling remove for the
material first? Most databases won't let you delete a row if another table
is referencing it, unless that particular db supports cascading deletes and
it's enabled. Typically in 1-M relationships like this (I assume you can
have more than one material per project) you have to delete the children
prior to deleting the parent. Hope this helps.

-----Original Message-----
From: Lawrence Fry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 03, 2000 2:56 AM
To: Orion-Interest
Subject: probs with bmp and foreign keys


Hello,

I am having problems with several bmp entity beans and foreign keys. I have
several beans, each bean corresponds to a table. One entity bean whose
primary key is a foreign key in several other beans is giving me problems. I
execute a remove on the the "mother" bean...and get all kinds of thrown
exceptions. The first is an SQL Exception on the removal of one row in the
project or "mother" table.

What am I doing wrong?

my tables:

create table project {
    projectid varchar(32) not null,
    userid varchar(32) not null,
    description varchar2(255),
    constraint project_pk primary key(userid,projectid)

create table material (
     materialid varchar2(32) not null,
     timestamp varchar2(19) not null,
     description varchar2(255),
     projectid varchar(32) not null,
     userid varchar(32) not null,
     constraint material_fk foreign key(projectid,userid)
              references project(projectid,userid),
     constraint material_pk primary
key(materialid,timestamp,projectid,userid));


I have an entity bean (bmp) for project and material. I have been having no
problems adding and removing projects or material entity beans with a
bean.remove() method....except when the entity bean pk for project is also
in material as a fk.

Orion throws this error when I execute a remove on a project bean which is
referenced in the material bean:

SQL Exception in remove ...

then  I get an IllegalStateException on the project entity bean...

It only goes down hill from there...

orion throws a DeadlockException in the project passivate method

then I get a MarshallingXAException error from Orion....Error while
delisting bean from TX.

Where did I go wrong?

Regards,

Lawrence




Reply via email to