New Posts New Posts RSS Feed: Delete Persistence Order
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Delete Persistence Order

 Post Reply Post Reply
Author
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Topic: Delete Persistence Order
    Posted: 22-Jul-2009 at 1:14pm
John:

I assume that the 1-to-M between Account and AccountAddress is implemented with a foreign key in AccountAddress that points to the parent Account. If Account also has a foreign key that points to AccountAddress (for the primary Address), then we can't know whether to delete AccountAddress entities first, or Account entities, because it depends upon what your user has done with the data in a particular session.

Personally, I would put a boolean field in the AccountAddress table to indicate whether a given AccountAddress record is a primary one, and then enforce a constraint that only one AccountAddress record in a set with the same parent Account be so designated.  Your Account.PrimaryAccountAddress property would then be a custom one that returns the one AccountAddress entity (if there is one) that is (a) a child of your Account instance and (b) is marked as a primary.

Back to Top
dobbo View Drop Down
Newbie
Newbie


Joined: 14-May-2008
Location: United Kingdom
Posts: 6
Post Options Post Options   Quote dobbo Quote  Post ReplyReply Direct Link To This Post Posted: 21-Jul-2009 at 7:32am
Hi all,
 
I have a database with three tables:
 
Account
AccountAddress
Address
 
These are used to describe a many to many relationship between Account and Address.
I also have a field in Account that points to a specific AccountAddress record to define the Primary Address when dealing with that account.
The relationships set up are as follows:
 
Account -> AccountAddress on the appropriate keys
Account -> AccountAddress pointing to a specific record on the appropriate key
AccountAddress -> Address on the appropriate keys.
 
Using Classic DevForce (3.6.2) and a CAB solution based on Cabana, I have a problem when I change the field in Account to point to a different AccountAddress record and delete the original AccountAddress.
 
When I save the Account record I then get an error show below:
 
 
I think this is because the persistence order or, perhaps an issue with our relationships, is wrong.
 
The error is pointing to the relationship pointing to the specific record.
 
If I save the content before deleting, then delete the original address it works but this is not an ideal solution.
 
Does anyone have any suggestions on how I can go about solving this problem.
 
Thanks
 
John
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down