Hi,
I'm in a bit of a pickle, and maybe because it's Friday I can't find a
solution. I'm converting data from our old system to our new system. So
contrary to how the program normally works, we now create all the data,
and then at the end call a massive Save.
My one hard-coded visitor is failing with a primary key violation, even
though I am using GUID's as a primary key. My first thought was
WTF, I thought GUID's are very unique! :)
Then I realized what is happening. Here is my class layout.
TLearner = class(...)
...
published
property Name: string ...;
property Surname: string ...;
property AddressList: TAddressList read ...;
property BillingAddress: TAddress ...; // a reference only
end;
BillingAddress is a reference to one of the addresses in AddressList.
So my TVisAddress_Save visitor is saving the address inside
AddressList, and then tries to save it again as BillingAddress - thus
causing the primary key violation in the DB.
Normally I would say, simply move BillingAddress to the Public section
of TLearner. But unfortunately it needs to be Published because I use
Model-GUI-Mediator (MGM) which gets and sets values via RTTI - thus
published properties are required.
Ummm, any ideas on how I can solve this?
I also tried to modify TVisAddress_Save.AcceptVisitor, but the
ObjectState can't be used because the GtiOPFManager.VisitorManager only
sets the ObjectState of all properties acted on, AFTER all objects have
been successfully visited. I also can't look for (Visited.Owner is
TLearner) because that will always be True, because the
AddressList.ItemOwner is set to the TLearner instance.
I guess my only option (possibly) is to create a custom MGM mediator
that doesn't require RTTI somehow... thus I can't use that mediator via
tiModelMediator. I'll try this now and see how far I get.
Any suggestions would be much appreciated.
--
Graeme Geldenhuys (System Analyst / Programmer)
[email protected]
----------------------------------------------------------
Master Maths Head Office Tel: (021) 851 5660
PO Box 573 · Somerset West Fax: (021) 851 5300
7129
www.mastermaths.co.za
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
tiOPF-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tiopf-talk