Hi Wally,
thanks for your response. Below you will find ddl and repository.
The relation is not defined as a non-decomposed m:n relation. And yes, I use
a primitive int to store the pk. Should I
give this special attention? For personId there is no reference-descriptor
defined as I have only read-access to this table
so OJB will never be forced to store data in it. that is why there is no
table TPPERSON in the repository. I am not sure if
this can work at all with OJB, I am just a newbie in this area. but, the
excpetion being thrown is an java.sql.SqlException and OJB passes it
through, so I begin thinking this has nothing to do with OJB. I am really
lost, hope you can help me.
Dirk
CREATE TABLE TPPERSON(
PERSON_ID INTEGER NOT NULL IDENTITY PRIMARY KEY,
PERSON_VNAME CHAR(32),
PERSON_NNAME CHAR(32) ...);
CREATE TABLE TPACTIVITY (
ACTIVITY_ID INTEGER NOT NULL IDENTITY PRIMARY KEY,
ACTIVITY_NAME CHAR(32) NOT NULL,
ACT_DEFERRABLE CHAR(3) NOT NULL,
MAN_HOURS INTEGER NOT NULL,
MILESTONE CHAR(3) NOT NULL,
ACTIVITY_TYPE_ID INTEGER NOT NULL,
PRIORITY_ID INTEGER NOT NULL,
PERSON_ID INTEGER,
VENTURE_ID INTEGER NOT NULL,
STATUS_ID INTEGER NOT NULL,
MODULE_ASSIGNED_ID INTEGER NOT NULL,
ACTIVITY_OWNER_ID INTEGER NOT NULL,
CREATION_DATE DATE NOT NULL,
VERSION_NR INTEGER NOT NULL,
VALID_FROM_TIMEPT TIMESTAMP NOT NULL,
VALID_TO_TIMEPT TIMESTAMP NOT NULL,
TIMESTAMP TIMESTAMP NOT NULL,
USERID CHAR(8) NOT NULL,
PROGRAM CHAR(32) NOT NULL,
ACTIVITY_DESC VARCHAR(254));
ALTER TABLE TPACTIVITY ADD CONSTRAINT FK_PERSON FOREIGN KEY (PERSON_ID)
REFERENCES TPPERSON(PERSON_ID);
ALTER TABLE TPACTIVITY ADD CONSTRAINT FK_MODULE_ASSIGNED FOREIGN KEY
(MODULE_ASSIGNED_ID) REFERENCES TMODULE(MODULE_ASSIGNED_ID)
<class-descriptor
class="de.premiere.plato.app.activity.entity.ActivityModel"
table="TPACTIVITY" >
<field-descriptor id="1" name="intActivityId"
column="ACTIVITY_ID" jdbc-type="INTEGER" primarykey="true"
autoincrement="true" />
<field-descriptor id="2" name="strActivityName"
column="ACTIVITY_NAME" jdbc-type="CHAR" />
<field-descriptor id="3" name="strActivityDeferrable"
column="ACT_DEFERRABLE" jdbc-type="CHAR" />
<field-descriptor id="4"
name="intActivityManHours"column="MAN_HOURS"
jdbc-type="INTEGER" />
<field-descriptor id="5" name="strActivityMilestone"
column="MILESTONE" jdbc-type="CHAR" />
<field-descriptor id="6" name="intActivityTypeId"
column="ACTIVITY_TYPE_ID" jdbc-type="INTEGER" />
<field-descriptor id="7" name="intPriorityId"
column="PRIORITY_ID" jdbc-type="INTEGER" />
<field-descriptor id="8" name="intPersonId"
column="PERSON_ID" jdbc-type="INTEGER" />
<field-descriptor id="9" name="intVentureId"
column="VENTURE_ID" jdbc-type="INTEGER" />
<field-descriptor id="10" name="intStatusId"
column="STATUS_ID" jdbc-type="INTEGER" />
<field-descriptor id="11"
name="intModuleAssignedId"column="MODULE_ASSIGNED_ID" jdbc-type="INTEGER"
/>
<field-descriptor id="12" name="intActivityOwnerId"
column="ACTIVITY_OWNER_ID" jdbc-type="INTEGER" />
<field-descriptor id="13" name="creationDate"
column="CREATION_DATE" jdbc-type="DATE" />
<field-descriptor id="14" name="versionNr"
column="VERSION_NR" jdbc-type="INTEGER" />
<field-descriptor id="15"
name="validFromTimepoint"column="VALID_FROM_TIMEPT"
jdbc-type="TIMESTAMP" />
<field-descriptor id="16" name="validToTimepoint"
column="VALID_TO_TIMEPT" jdbc-type="TIMESTAMP" />
<field-descriptor id="17" name="timestamp"
column="TIMESTAMP" jdbc-type="TIMESTAMP" />
<field-descriptor id="18" name="strUserId"
column="USERID" jdbc-type="CHAR" />
<field-descriptor id="19" name="strProgram"
column="PROGRAM" jdbc-type="CHAR" />
<field-descriptor id="20" name="strActivityDescription"
column="ACTIVITY_DESC" jdbc-type="VARCHAR" />
<reference-descriptor name="moduleAssignedModel"
class-ref="de.premiere.plato.app.module.entity.ModuleAssignedModel"
refresh="true"
auto-retrieve="true" >
<foreignkey field-id-ref="11" />
</reference-descriptor>
</class-descriptor>
-----Urspr�ngliche Nachricht-----
Von: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 8. Januar 2004 15:40
An: OJB Users List
Betreff: RE: integrity constraint violation
Vertraulichkeit: Pers�nlich
Hi Dirk,
Can you post the relevant DDL and repository? Is the person-activity
relation defined as a non-decomposed m-n relation? I suspect you have a
constraint set in the DDL that prevents the relation from being stored. As
far as the 0 is concerned, do you use a primitive int or an Integer object
to store your PK? If you use a primitive, a zero is the default value that
OJB will interpret as null.
Good luck,
Wally Gelhar
-----Original Message-----
From: Dirk Manske (Service Respond)
[mailto:[EMAIL PROTECTED]
Sent: Thursday, January 08, 2004 4:54 AM
To: 'OJB Users List'
Subject: AW: integrity constraint violation
Sensitivity: Personal
Hi there,
can anyone give me a hint about my problem (see below)? if I have the
following two tables
*************************************************************** *
*****************************************************************
* Table PERSON *
* Table ACTIVITY *
*-------------------------------------------------------------------------
* _0..1________N_ * -----------------
--------------------------------------------------------- *
* personId INTEGER NOT NULL Identity Primary Key *
* activityId INTEGER NOT NULL Identity Primary Key *
* .... *
* personId INTEGER (foreign key) *
* ... *
with a 0..1-to-many relation. both tables are empty. it should be possible
to create an activity and store it without assigning a person, right?!
However I get a violated constraint exception for table PEERSON, although I
did not setup any value for personId as no row exists in table person. after
traced the exception message I found out, that for the attribute person_id
OJB generated a 0 value and tries to store it and I just read in another
message that there is a 0-null problem for OJB. Am I facing exact this
problem?
help appreciated!
thx,
Dirk
-----Urspr�ngliche Nachricht-----
Von: Dirk Manske (Service Respond)
[mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 7. Januar 2004 18:56
An: [EMAIL PROTECTED]
Betreff: integrity constraint violation
Hi,
I have got a problem with referential integrity. I am using OJB PB API with
HSQLDB and have set up a table 'person' with personId as primary key and a
second table 'activity' with this attribute as foreign key (null allowed).
the datatyp is integer and the association is 0..1 to many.
It should be possible to store an activity and assign a person later to it.
however, when I try to store an activity I get the following exception:
org.apache.ojb.broker.KeyConstraintViolatedException ....
java.sql.SqlException: integrity constraint violation for table 'person'.
What am I doing wrong?
thx,
Dirk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]