Hi again,
I got the "Misterious" but have already another one ...
As I am copying data from an relational database - with recursive stored
data in it,
I thought to do it on several Import Mathod calls...
But - %Save does not update any Property
because I set a Uniq Index - to prevent multiple inserts...
So therefore in one Case the Type Property was not set - in the first step
(root of tree) I decided to let it unset,
and so it was still because I did a little mistake an loaded too much rowas
in the first step.
But:
=> How can I Update Properties when an Object/Record still exists...
%Save does not - or ?
Here is the Class - with the unique Index on DOCID (the external key of the
old database):
####################################################################
Class GAS.DocumentType Extends GAS.NLSObject [ ClassType = persistent,
ProcedureBlock ]
{
Parameter EXTENTSIZE = 0;
Property DOCID As %Numeric;
Property DocumentType As DocumentType;
Relationship ToObjectType As GAS.DocumentTypeReference [ Cardinality = many,
Inverse = FromDocumentType ];
Property TypeTree As DocumentType [ Collection = list ];
Index DOCIDIndex On DOCID [ Unique ];
Index DocumentTypeIndex On DocumentType;
Method DocumentTypeSet(Arg As DocumentType) As %Status
{
set i%DocumentType = Arg
if (Arg) {
For i = 1:1:Arg.TypeTree.Count() {
Do ..TypeTree.Insert(Arg.TypeTree.GetAt( i ) )
}
}
Do ..TypeTree.Insert(Arg)
Quit $$$OK
}
<Storage name="Default">
<Data name="DocumentTypeDefaultData">
<Subscript>"DocumentType"</Subscript>
<Value name="1">
<Value>DOCID</Value>
</Value>
<Value name="2">
<Value>DocumentType</Value>
</Value>
<Value name="3">
<Value>TypeTree</Value>
</Value>
</Data>
<DefaultData>DocumentTypeDefaultData</DefaultData>
<Type>%Library.CacheStorage</Type>
</Storage>
And there is also the "new Mistery":
As I was not sure why in one class the property was set - I first took a
look at the
Class Storage ...
And there was a deleted Property still in it - so I deleted the <Storage...
text
and did a new compile,
but then - oh Mistery - there were also the Properties of the derived Class
here ?
And I could not Save any data - Index not Unique - but no data in the table
(I deleted it with the SQL Manager)
Now I droped the table, did a compile again and so on, and so on....
Deleted the derived Properties in the Class Storage and so on ...
But: it still does not work yet again ???
Any idea how to "repair" the table ???
brg
werner
"Ram�n Jim�nez" <rjimenez@@@cicla..com...do> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Werner,
>
>
> > how can I reset or initialize the Property "TypeTree" ?
> >
> > I think I have to do this when .Insert adds Items -
> > but "set ..TypeTree = null" do not work - is not accepted by the
compiler
> > as I would have done in other programming languages ?
>
> Indeed, it's a bit misleading. But as I said, these collections are
> initialized by Cach� on object creation and we are not meant to deal with
> them as if they were ordinary objects (at least I've never tried!)
>
> You could do
>
> Set ..TypeTree = $$$NULLOREF
>
> and this is Cach�'s semantically equivalent for e.g. Java's " oref =
null",
> but I'm afraid this would wreak havoc. So instead let's try the more
> conservative:
>
> Do ..TypeTree.Clear()
>
> Bear in mind though that this only clears the list pointers, not the
in-disk
> objects pointed to by the list... The latter requires a loop deleting and
> removing elements one by one, something along the lines of
>
> While ..TypeTree.Count() > 0 {
> Set Oid = ..TypeTree.RemoveAt( 1 )
> Do ##class(ReferredObject).%Delete(Oid)
> }
>
> You can verify these idioms with test data, by looking at the data itself
> after the operations.
>
> > And the second urgent question is:
> >
> > I have 2 Classes with this Method - in the first one, the line
> > > set i%ObjectType = Arg
> > works fine
> >
> > in the second one the column in the table is still empty ?
>
> Hmmm... Misterious...
>
> I once (and only once!) read something about a "r%ObjectType" convention
but
> now I forget... I guess it was something like "i% expects OREFs, r%
expects
> OIDs". Typically you will never need to use, definitely not if "Arg" above
> is an instantiated object in the current process...
>
> > Do I need to call ..%Save in the overloaded PropertySet Method ?
> > I hope not - because if there is an other triggered method ... !
>
> Nope - this should not be necessary.
>
> > So I can not imagine the difference ?
> >
> > there is the code snippet:
>
> [snip]
>
> Only tricky thing I see is that I don't know where "typeid" comes from in
> both examples, I assume you also wrote those to screen to ensure they have
> proper values?
>
> Other than that, you coud change
>
> do new.%Save()
>
> with
>
> Set sc = new.%Save()
> If $$$ISERROR(sc) DO $system.OBJ.DisplayError(sc)
>
> This is considered "best practice" and will shed more light on this
> otherwise curious behavior.
>
> > thanks a lot - and I hope we can discuss the other features of cache
also
> > later on ... !
>
> And thank *you* for taking the time to make yourself clear and testing a
lot
> :) Looking forward to those discussions!
>
> HTH,
>
> Ram�n
>
>