class ObjectReferentialRepository {

    public Optional<TapeObjectReferentialEntity> find(String containerName, String objectName)
        throws ObjectReferentialException {

        Document document;
        try {
            document = collection.find(
                Filters.eq(TapeObjectReferentialEntity.ID,
                    toBson(new TapeLibraryObjectReferentialId(containerName, objectName))))
                .first();
        } catch (MongoException ex) {
            throw new ObjectReferentialException("Could not find storage location by id " +
                containerName + "/" + objectName, ex);
        }

        if (document == null) {
            return Optional.empty();
        }

        try {
            return Optional.of(fromBson(document, TapeObjectReferentialEntity.class));
        } catch (InvalidParseOperationException e) {
            throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e);
        }
    }

    public  ObjectReferentialRepository(MongoCollection<Document> collection);

}