Postby allistar » Mon May 12, 2014 9:09 am
Comparing types by name is the best approach as it removes the subschema copy problem. The other thing worth mentioning is to not store references to type objects (e.g. Classes) on other persistent object. The reason is that when a class is reorged the object for the class changes, and so your pointer to that class either points to an invalid object, or it points to a different class. It's fine to do this for transient objects though because by definition they cannot exist across a reorg.
If you use class name it makes sense to also store the schema name. We tend to use class number as that is stable, and it's unique globally in a database. Unfortunately JADE's implementation of Schema::getClassByNumber is very slow if you have a large number of classes, so we have a transient cache of class number to class maps. (On our system each call to Schema::getClassByNumber in multiuser is about 18ms, which is an eternity. From what I understand it recurses the schemas to find the class).