• creating a dm_note: session.newObject will do
  • attach a dm_note to a sysobject: IDfNote.addNote
  • detach a dm_note: IDfNote.removeNoteEx
  • the relationship is stored in dm_relation with relation_name='DM_ANNOTATE'
  • check in a new version of dm_note object won't update dm_relation automaticly, you need to detach the old version of dm_note and attach the new version of dm_note manually.
  • inside dm_relation, child_id is not r_object_id of dm_note. It's the i_chronicle_id. so you need to use child_id and child_label to retrieve the right dm_note object as complex as:

String dql = "Select child.r_object_id as object_id from dm_sysobject (all) child, dm_relation relation where " +
"((child.i_chronicle_id = relation.child_id and any child.r_version_label = relation.child_label) " +
"or (child.r_object_id = relation.child_id and relation.child_label is nullstring)) " +
"and relation.relation_name='DM_ANNOTATE' and relation.parent_id= '" + doc.getObjectId().toString() + "'" ;

IDfQuery query = sMgr.getQuery();
col = query.execute(session, IDfQuery.DF_READ_QUERY);
while (col.next()) {
    IDfTypedObject object = col.getTypedObject();
    IDfNote note = (IDfNote) session.getObject(object.getId("object_id"));
    log("\tnote: " + note.getObjectId().toString() + ", with name: " + note.getObjectName());