I am trying to controll my media entities by creating a repository.
How to create a repository for the GalleryHasMedia class?
namespace Application\Sonata\MediaBundle\Repository;
use Doctrine\ORM\EntityRepository;
class GalleryHasMediaRepository extends EntityRepository
{
    /**
     * @param integer $galleryId
     * @return array
     */
    private function findMediaOfGallery($galleryId)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('gm')
           ->from('ApplicationSonataMediaBundle:GalleryHasMedia', 'gm')
           ->where('gm.gallery_id = :gallery')
           ->setParameters(['gallery' => $galleryId]);
        return $qb->getQuery()->getResult();
    }
}
Application\Sonata\MediaBundle\Resources\config\doctrine\GalleryHasMedia.orm.xml
repository-class="Application\Sonata\MediaBundle\Repository\GalleryHasMediaRepository"
Application\Sonata\MediaBundle\Entity\GalleryHasMedia.php
namespace Application\Sonata\MediaBundle\Entity;
use Sonata\MediaBundle\Entity\BaseGalleryHasMedia as BaseGalleryHasMedia;
use Sonata\MediaBundle\Model\GalleryInterface as GalleryInterface;
use Sonata\MediaBundle\Model\MediaInterface as MediaInterface;
class GalleryHasMedia extends BaseGalleryHasMedia
{
    ...
}
Error:
Undefined method 'findMediaOfGallery'. The method name must start with either findBy or findOneBy! 
Please tell how to fix it?
config.yml
# Doctrine Configuration
doctrine:
    orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true
When I write a non-existent class here: GalleryHasMedia.orm.xml there are error messages.