@Test
public void testHasMetadataId() throws Exception {

    Metadata metadata1 = _metadataRepo.save(newMetadata(_inc));
    Metadata metadata2 = _metadataRepo.save(newMetadata(_inc));
    MetadataRelation relation = new MetadataRelation();
    relation.setId(new MetadataRelationId(metadata1.getId(), metadata2.getId()));
    _repo.save(relation);
    assertEquals(1, _repo.count(hasMetadataId(metadata1.getId())));
    assertEquals(0, _repo.count(hasMetadataId(metadata2.getId())));
}