defect
In the database definition for "Tag," there is a reference called "taggedObject." Its target type is the abstract type "Object," but it is monomorphic; that is, the database does not store the specific type of the tagged object.
If you try to store something in this reference (e.g., a Group), an error occurs
Caused by: com.top_logic.element.meta.AttributeException: com.top_logic.dob.ex.IncompatibleTypeException: Value must have type 'Object' but has 'Group'
at com.top_logic.element.meta.kbbased.storage.AbstractStorage.update(AbstractStorage.java:92)
at com.top_logic.element.meta.AttributeUpdate$DefaultStorageAlgorithm.store(AttributeUpdate.java:80)
at com.top_logic.element.meta.AttributeUpdate.store(AttributeUpdate.java:654)
at com.top_logic.element.meta.form.overlay.FormObjectOverlay.store(FormObjectOverlay.java:322)
at com.top_logic.element.meta.AttributeUpdateContainer.store(AttributeUpdateContainer.java:699)
at com.top_logic.element.meta.form.AttributeFormContext.store(AttributeFormContext.java:143)
at com.top_logic.element.layout.grid.DefaultGridApplyHandler.storeChanges(DefaultGridApplyHandler.java:30)
at com.top_logic.element.layout.grid.GridComponent.storeRowValues(GridComponent.java:1413)
... 67 more
Caused by: com.top_logic.dob.ex.IncompatibleTypeException: Value must be of type 'Object' but is of type 'Group'
at com.top_logic.knowledge.KnowledgeReferenceStorageImpl.checkType(KnowledgeReferenceStorageImpl.java:186)
at com.top_logic.knowledge.KnowledgeReferenceStorageImpl.checkAttributeValue(KnowledgeReferenceStorageImpl.java:95)
at com.top_logic.knowledge.service.db2.DBKnowledgeItem.setValue(DBKnowledgeItem.java:268)
at com.top_logic.knowledge.service.db2.DynamicKnowledgeItem.setAttributeValue(DynamicKnowledgeItem.java:124)
at com.top_logic.element.meta.kbbased.storage.ForeignKeyStorage.storeReferencedTLObject(ForeignKeyStorage.java:167)
at com.top_logic.element.meta.kbbased.storage.TLItemStorage.internalSetAttributeValue(TLItemStorage.java:112)
at com.top_logic.element.meta.AbstractStorageBase.setAttributeValue(AbstractStorageBase.java:81)
at com.top_logic.element.meta.kbbased.storage.AbstractStorage.update(AbstractStorage.java:88)
... 74 more
Side note: Since the "Tag:Tag#taggedObject" attribute in the model uses "historic-storage," the problem is not apparent.
Migration
- The migrations Ticket_29361_Made_Tag_taggedObj_polymorphic and Ticket_29361_Move_taggedObj_to_Tag_table (module tl-element) automatically convert the reference Tag:Tag#taggedObject automatically (polymorphic, new column TAGGED_OBJ_TYPE, stored as a foreign key in the Tag table). No manual action is required unless the application extends the Tag schema itself.
- Schema validation has been tightened: A monomorphic reference whose target type is an abstract MOClass or an MOAlternative will be rejected with a DataObjectException ("... must be a non-abstract class") when the schema is resolved, rather than failing with an IncompatibleTypeException only when a value is saved. You must declare your own *Meta.xml files containing such a reference as polymorphic or have them point to a concrete type; otherwise, the application will not start.
- Migration API: Util.updateTLReference(...), Util.updateInverseReference(...), and Util.updateTLStructuredTypePart(...) (com.top_logic.model.migration) have an additional parameter, DeletionPolicy, after HistoryType (null leaves the value unchanged). Custom migration processors that call these methods must be adapted.