Hi all,
The legacy DB I'm currently working with is designed around compound PKs. Let's 
take a part of three tables as an example:

Company
- company_id (pk)

Customer
- company_id (pk)
- customer_id (pk)

Invoice
- company_id (pk)
- document_number (pk)
- customer_id

* Invoice and Customer are related to Company on [company_id] (these objects 
always "belong" to a company)
* Customer is related to Invoice on [company_id] and [customer_id]

The relationships are modeled and this has worked fine for read operations with 
Cayenne.

However, I'm hitting a problem now that I'm starting to write to the DB: If I 
set the customer object on Invoice to null, Cayenne will (obviously) null out 
both [company_id] and [customer_id] on Invoice. However, the desired behaviour 
would be to set only [customer_id] to null and keep company_id unchanged.

Can anyone imagine a workaround to achieve the desired behaviour? Or is it just 
time for me to bite the bullet, expose all FKs and manage them manually, until 
I've beaten some sense into the DB?

Cheers,
- hugi

Reply via email to