Re: odmg/foreign key contraint fails

2003-10-30 Thread Gunnar Hilling
By the Way: I'm using ManageableSet for my Collections (both) and ojb from
cvs (maybe one week old).

-Gunnar



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: odmg/foreign key contraint fails

2003-10-30 Thread Gerhard Grosse
Hi again,

According to the docs, the auto-xy options should be left at their
defaults for ODMG to work correctly. I'm not sure how this really
affects things, but obviously something goes wrong with
auto-update=true.

The remaining problem is probably solved by doing both a
zz.addOption(o1) *and* o1.setZertifikat(zz) (or similar).

I guess it is arguable whether this should be necessary, but in my
view this makes sense, because otherwise the objects to store are
basically inconsistent, and the ODMG layer has to guess what to do. It
may seem obvious what to do when first inserting the objects, but
later if you say o1.setZertifkat(null) without zz.removeOption(o1),
the objects are in the same state, and it is not at all clear what the
intended behavior should be.

In my object models I usually include o1.setZertifikat(this) in the
method zz.addOption().

Cheers,
Gerhard


On Thu, 30 Oct 2003 14:14:58 +0100, Gunnar Hilling
[EMAIL PROTECTED] wrote:

On Thu, 30 Oct 2003 08:58:33 +0100, Gerhard Grosse wrote:

Hello Gerhard,

Thanks for your Proposal. I think the problem is somewhere where you
pointed out.
But it't not exactly what you proposed. I think there is a problem whith
auto-update and auto-retrieve- Options. If Option is auto-updated
from Zertifikatschein AND from Zertifikat there is an error with a
duplicated primary key.
Seems the same options is tried to be written twice. If I remove the
auto-update from Zertifikat this is OK, but the foreign key for
Zertifikat will not be written to Option...
So what should I do??

Regards,

-Gunnar



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: odmg/foreign key contraint fails

2003-10-30 Thread Gunnar Hilling
Hi Gerhard,

At first I'd like to thank You for the hints!

 Hi again,
 
 According to the docs, the auto-xy options should be left at their
 defaults for ODMG to work correctly. I'm not sure how this really
 affects things, but obviously something goes wrong with
 auto-update=true.
 
 The remaining problem is probably solved by doing both a
 zz.addOption(o1) *and* o1.setZertifikat(zz) (or similar).
 
 I guess it is arguable whether this should be necessary, but in my
 view this makes sense, because otherwise the objects to store are
 basically inconsistent, and the ODMG layer has to guess what to do. It
 may seem obvious what to do when first inserting the objects, but
 later if you say o1.setZertifkat(null) without zz.removeOption(o1),
 the objects are in the same state, and it is not at all clear what the
 intended behavior should be.
 
 In my object models I usually include o1.setZertifikat(this) in the
 method zz.addOption().
 
 Cheers,
 Gerhard

I could do that. But I thought this would work automatically when using
the appropriate (This is also done in the examples/tests).


Thanks,

-Gunnar



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



odmg/foreign key contraint fails

2003-10-29 Thread Gunnar Hilling
Hello, 
I got a problem with the following code snippet:  

  tx.begin();

System.out.println(creating +3*NUM+ records);
t0=System.currentTimeMillis();
for(int i=0; iNUM; i++){
customer=new Customer(no, one, here, +System.currentTimeMillis(), 
eternity, 2, new Date());
db.makePersistent(customer);
Zertifikatschein z1=new Zertifikatschein(Z1);
Zertifikat zz=new Zertifikat();
db.makePersistent(zz);
Option o1=new Option();
zz.addOption(o1);
z1.addOption(o1);
customer.addSchein(z1);
customer.addSchein(new Zertifikatschein(Z2 ));
System.out.print(.);
}
t1=System.currentTimeMillis();
System.out.println(\n + (t1-t0) +  msec);
tx.commit();

(Relations:
customer - n Zertifikatschein - n Option m - Zertifikat)

When committing, I get the following error:

ERROR:  option_fk_2 referential integrity violation -
key referenced from option not found in zertifikat

OK, this is the relation from Option to Zertifikat
(bidirectional). If i remove the foreign key constraint
(navigability) from Option all works out fine
AND: the foreign keys are all there in the Option table ...

What have I done (wrong...)?

Best Regards,

-Gunnar

PS: Project Schema follows

?xml version=1.0 encoding=ISO-8859-1 standalone=no ?
!DOCTYPE database SYSTEM http://jakarta.apache.org/turbine/dtd/database.dtd;
!-- Generated by the xdoclet-ojb module --

database name=lotto

table name=customer
column name=key
javaName=key
type=INTEGER
primaryKey=true
required=true
autoIncrement=true
/
column name=vorname
javaName=vorname
type=VARCHAR
size=24
/
column name=nachname
javaName=nachname
type=VARCHAR
size=64
/
column name=anrede
javaName=anrede
type=VARCHAR
size=24
/
column name=strasse
javaName=strasse
type=VARCHAR
size=24
/
column name=plz
javaName=plz
type=INTEGER
/
column name=wohnort
javaName=wohnort
type=VARCHAR
size=24
/
column name=geburtsdatum
javaName=geburtsdatum
type=TIMESTAMP
/
column name=benutzername
javaName=benutzername
type=VARCHAR
size=24
/
column name=kundennummerttcall
javaName=kundennummerttcall
type=VARCHAR
size=24
/
column name=email
javaName=email
type=VARCHAR
size=24
/
column name=status
javaName=status
type=VARCHAR
size=24
/
/table

table name=zertifikat
column name=key
javaName=key
type=INTEGER
primaryKey=true
required=true
autoIncrement=true
/
/table

table name=reservierung
column name=id
javaName=id
type=INTEGER
primaryKey=true
required=true
autoIncrement=true
/
column name=startdate
javaName=startdate
type=TIMESTAMP
/
column name=enddate
javaName=enddate
type=TIMESTAMP
/
column name=optionen
javaName=optionen
type=VARCHAR
size=511
/
column name=tippId
javaName=tippId
type=INTEGER
/
column name=zertifikatId
javaName=zertifikatId
type=INTEGER
/
foreign-key foreignTable=tipp
reference local=tippId foreign=id/
/foreign-key
foreign-key foreignTable=zertifikat
reference local=zertifikatId foreign=key/
/foreign-key
/table

table name=tipp
column name=id
javaName=id
type=INTEGER
primaryKey=true
required=true
/
/table

table name=product
column name=key
javaName=key
type=INTEGER
primaryKey=true
required=true
autoIncrement=true
/
column name=startWoche
javaName=startWoche
type=TIMESTAMP
/
column name=zertifikatId
javaName=zertifikatId
type=INTEGER
/
foreign-key foreignTable=zertifikat
reference local=zertifikatId foreign=key/
/foreign-key