you should handle the case of ``$dm`` being ``null`` (i.e. someone using the constraint on a class not managed by the PHPCR ODM)