You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by hal arnold <ha...@yahoo.com> on 2003/05/06 22:03:13 UTC

help for a newbie on 1:N inserts

Hi,

I'm following (as close as I can) the instructions
with the example for 1:N 'inserts' that uses Products
and Articles.
I've got what looks to be an identical example using a
TestBusinessObject (as the enclosing parent) and
TestBizItem
which is the collection in the TestBusinessObject.

What it's (not) doing:

When I run the junit test that is supposed to create
the parent, create two items, add the two items to the
parent and
message the parent with the store, it creates all the
objects (as evidenced by what's in the db), but
doesn't put the 
foreignKey for the parent into each of the kiddies.

 I've got p6Spy hooked up and this is the sql call
trace (minus the trace numbers):

SELECT MAX(ID) FROM TESTBIZITEM
SELECT
A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM
OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  ? ) AND
A0.FIELDNAME LIKE  ? |SELECT
A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM
OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE 
'SEQ_TESTBIZITEM' ) AND A0.FIELDNAME LIKE  'ID' 
UPDATE OJB_HL_SEQ SET MAX_KEY=?, GRAB_SIZE=? WHERE
TABLENAME = ?  AND FIELDNAME = ? |UPDATE OJB_HL_SEQ
SET MAX_KEY='165', GRAB_SIZE='5' WHERE TABLENAME =
'SEQ_TESTBIZITEM'  AND FIELDNAME = 'ID' 
commit||
|SELECT MAX(ID) FROM TESTBUSINESSOBJECT
SELECT
A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM
OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  ? ) AND
A0.FIELDNAME LIKE  ? |SELECT
A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM
OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE 
'SEQ_TESTBUSINESSOBJECT' ) AND A0.FIELDNAME LIKE  'ID'

UPDATE OJB_HL_SEQ SET MAX_KEY=?, GRAB_SIZE=? WHERE
TABLENAME = ?  AND FIELDNAME = ? |UPDATE OJB_HL_SEQ
SET MAX_KEY='267', GRAB_SIZE='5' WHERE TABLENAME =
'SEQ_TESTBUSINESSOBJECT'  AND FIELDNAME = 'ID' 
commit||
SELECT NAME,ID FROM TESTBUSINESSOBJECT WHERE ID = ?
|SELECT NAME,ID FROM TESTBUSINESSOBJECT WHERE ID =
'263' 
INSERT INTO TESTBUSINESSOBJECT (ID,NAME) VALUES ( ?, ?
) |INSERT INTO TESTBUSINESSOBJECT (ID,NAME) VALUES (
'263', 'testParent' ) 
SELECT TEST_BUSINESS_OBJECT_ID,NAME,ID FROM
TESTBIZITEM WHERE ID = ? |SELECT
TEST_BUSINESS_OBJECT_ID,NAME,ID FROM TESTBIZITEM WHERE
ID = '161' 
INSERT INTO TESTBIZITEM
(ID,NAME,TEST_BUSINESS_OBJECT_ID) VALUES ( ?, ?, ? )
|INSERT INTO TESTBIZITEM
(ID,NAME,TEST_BUSINESS_OBJECT_ID) VALUES ( '161',
'test1', '' ) 
SELECT TEST_BUSINESS_OBJECT_ID,NAME,ID FROM
TESTBIZITEM WHERE ID = ? |SELECT
TEST_BUSINESS_OBJECT_ID,NAME,ID FROM TESTBIZITEM WHERE
ID = '162' 
INSERT INTO TESTBIZITEM
(ID,NAME,TEST_BUSINESS_OBJECT_ID) VALUES ( ?, ?, ? )
|INSERT INTO TESTBIZITEM
(ID,NAME,TEST_BUSINESS_OBJECT_ID) VALUES ( '162',
'test2', '' ) 
commit||

Alas, when it does the inserts into testBizItem, the
last field is empty and should have the value '263'. I
know I'm being addled here, but I can't see what the
error might be... 

Any help would greatly be appreciated,

Hal Arnold

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com