Here is a test project (Run ApplicationJDOTest file using JUnit).

Notes:
- testMapping and testDatabase files are in the "properties" directory.
- Before running please check the path for the testMapping file in
testDatabase.xml. Check also the testMapping and the testDatabase file
path in OpenCSTestCase.java.

If you run the test program you will get an error: Cannot affect null
value to not null column.

If you remove in the ddl file the "not null" beside CLI_ID the test will
work but in the database the CLI_ID for "Test Application 1" will be
null.

"Test Application 2" works because it is in the same transaction (not
using the long transaction). 

Thanks

-----Message d'origine-----
De�: Bruce Snyder [mailto:ferret@;frii.com] 
Envoy�: lundi 28 octobre 2002 17:41
��: [EMAIL PROTECTED]
Objet�: Re: [castor-dev] Problem in inserting table with foreign key

This one time, at band camp, Guy Di Fulvio said:

GDF>Anything new on this subject? (Problem in inserting table with
foreign
GDF>key)
GDF>
GDF>Thanks!
GDF>
GDF>-----Message d'origine-----
GDF>De�: Dave Carlson [mailto:dcarlson@;ontogenics.com] 
GDF>Envoy�: jeudi 3 octobre 2002 23:23
GDF>��: [EMAIL PROTECTED]
GDF>Objet�: Re: [castor-dev] Problem in inserting table with foreign key
GDF>
GDF>This is exactly the same problem that I posted in a message several
days
GDF>ago,
GDF>but got no responses.  To elaborate using your example, if I set
GDF>db.setAutoStore(true) using a long transaction like yours, then the
GDF>Client
GDF>foreign is inserted, but JDO also inserts a NEW duplicate copy of
Client
GDF>in the
GDF>database (using a new identify generated for the new insert).
GDF>
GDF>-- Dave
GDF>
GDF>----- Original Message -----
GDF>From: "Guy Di Fulvio" <[EMAIL PROTECTED]>
GDF>To: <[EMAIL PROTECTED]>
GDF>Sent: Thursday, October 03, 2002 2:35 PM
GDF>Subject: [castor-dev] Problem in inserting table with foreign key
GDF>
GDF>
GDF>> Hi,
GDF>>
GDF>> I am trying to insert in a database a new record WApplication (see
GDF>> below) this record depends on WClient which is already in the
GDF>database.
GDF>> If I don't use the long transactions and do everything between the
GDF>same
GDF>> begin and commit this works perfectly.
GDF>> However if I try to use the long transactions it does not work
GDF>> (uncomment below and see).
GDF>>
GDF>> So what is wrong with what I did?
GDF>>
GDF>> Thanks,
GDF>> Guy
GDF>>
GDF>> ---------
GDF>>
GDF>> Version:
GDF>> Castor 0.9.3.21
GDF>>
GDF>> Test Code:
GDF>> // Create new WClient
GDF>> ...
GDF>>      _db.commit();
GDF>> _db.close();
GDF>>
GDF>> _db = getDatabase();
GDF>> _db.setAutoStore(false);
GDF>> _db.begin();
GDF>>
GDF>> // load Client (1)
GDF>> ...
GDF>>
GDF>> // If I uncomment the following lines the foreign key (CLI_ID is
null)
GDF>> // _db.commit();
GDF>> // _db.close();
GDF>>
GDF>> // create new WApplication
GDF>> ...
GDF>> application.setClient(client);
GDF>>
GDF>> // If I uncomment the following lines the foreign key (CLI_ID is
null)
GDF>> // _db = getDatabase();
GDF>> // _db.setAutoStore(false);
GDF>> //    _db.begin();
GDF>>     _db.create(application);
GDF>>     _db.commit();
GDF>> _db.close();

Guy, 

Can you jar up a small test for this including your client code, mapping
descriptor and DDL? This would be very helpful in tracking down this
problem. 

Bruce
-- 
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Attachment: test.zip
Description: Binary data

Reply via email to