Wiggins d'Anconia wrote:
> Hopefully I didn't overlook this too.
> 
> Is it possible to do a four level deep cascading save? In other words I
> have relationships where,
> 
> 1. Company -> one to many offerings
> 2. Offering -> one to many sequences
> 3. Sequence -> one to many levels
> 
> I *believe* that I have the proper data structure setup such that I can do,
> 
> $company->offerings( [EMAIL PROTECTED] );
> $company->save;
> 
> And assuming Rose knows to DWIM it should work, but I am getting an FK
> constraint error telling me that upon saving the 'level' that the
> 'sequence' does not exist.
> 
> It certainly could be a problem in my data structure, but before I spend
> more time debugging it, I thought I would confirm that it should be working.
>

Sorry for the noise, I had forgotten about the ::Debug flag. After
turning it on it appears that Rose is doing an UPDATE instead of an
INSERT for the sequence. Here is the dump, note the offset update
statement. Is this a bug, if not can someone enlighten how to make this
right, or why I shouldn't be employing this technique? It appears that
in the select statement immediately preceding the update, that the
primary key of the current object (the one just inserted) is not
detected properly, causing detection of a record that already exists.

INSERT INTO employer
(
  company_code,
  date_created,
  last_modified,
  name,
  update_user
)
VALUES
(
  ?,
  ?,
  ?,
  ?,
  ?
) - bind params: SIN3, now, , Company Name,
SELECT browse, company_code, date_created, discrete_sequences, eid,
last_modified, sort_order, update_user, years FROM offerings WHERE
company_code = ? AND eid = ? AND years = ? - bind params: SIN3, , 25
INSERT INTO offerings
(
  browse,
  company_code,
  date_created,
  discrete_sequences,
  eid,
  last_modified,
  sort_order,
  update_user,
  years
)
VALUES
(
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?
) - bind params: 1, SIN3, now, 1, , , 5, , 25
SELECT browse, company_code, date_created, eid, last_modified,
sequence_number, update_user, years FROM offering_sequences WHERE
company_code = ? AND eid = ? AND years = ? AND sequence_number = ? -
bind params: , , 25, 0

*NOTE: In the above bind params the 'company_code' should be 'SIN3'.*

UPDATE offering_sequences SET
    browse = ?,
    date_created = ?,
    last_modified = ?,
    update_user = ?
WHERE company_code = ? AND eid = ? AND years = ? AND sequence_number = ?
- bind params: 1, 2006-04-04 18:21:20.690816, 2006-04-04
18:21:20.690816, giftnet, SIN3, , 25, 0



SELECT browse, catalog_code, catalog_level, company_code, date_created,
eid, last_modified, sequence_number, update_user, years FROM
offering_levels WHERE company_code = ? AND eid = ? AND years = ? AND
sequence_number = ? AND catalog_code = ? AND catalog_level = ? - bind
params: , , , 0, HZNO04, P
INSERT INTO offering_levels
(
  browse,
  catalog_code,
  catalog_level,
  company_code,
  date_created,
  eid,
  last_modified,
  sequence_number,
  update_user,
  years
)
VALUES
(
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?,
  ?
) - bind params: 1, HZNO04, P, SIN3, now, , , 0, , 25
DBD::Pg::st execute failed: ERROR:  insert or update on table
"offering_levels" violates foreign key constraint "fk_offering_levels"
DETAIL:  Key (company_code,eid,years,sequence_number)=(SIN3,,25,0) is
not present in table "offering_sequences".


> Thanks again,
> 
> http://danconia.org
> 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to