Matrix m = mh.findPersistedObjectByID(Matrix.class, id);
if (m == null) return;
if (m instanceof CharacterMatrix) {
CharacterMatrix cm = (CharacterMatrix) m;
mh.cascadeDeleteRows(cm.getRowsReadOnly());
mh.cascadeDeleteElements(cm);
mh.cascadeDeleteColumns(cm);
}
mh.delete(m);
}