无法通过存储库中的标识变量选择实体

I have the following query. The query is inside my InstagramShopPicture

$queryBuilder = $this->createQueryBuilder('p')
                    ->select('p.id, p.caption, p.price, p.lowresimageurl, p.medresimageurl, p.highresimageurl, p.numberoflikes, p.numberofdislikes, shop.id, shop.username, shop.fullname, contact, category')
                    ->leftJoin('p.shop', 'shop')
                    ->leftJoin('shop.contact', 'contact')
                    ->leftJoin('p.category', 'category')
                    ->leftJoin('category.pictureTopCategory', 'pictureTopCategory')
                    ->leftJoin('category.pictureFirstLevelCategory', 'pictureFirstLevelCategory')
                    ->leftJoin('category.pictureSecondLevelCategory', 'pictureSecondLevelCategory')
                    ->where('p.isLocked = false')
                    ->andWhere('p.isStyleInspiration = false')
                    ->andWhere('shop.isLocked = false');

I am however getting the following error:

QueryException: [Semantical Error] line 0, col -1 near 'SELECT p.id,': Error: Cannot select entity through identification variables without choosing at least one root entity alias

any idea on how to solve this?

Seems you are trying to make joins without using aliases for your tables.

This chould cause you a lot of problems, particularly when column names are identical

     ->leftJoin('p.category', 'category') // aliasing
    ->leftJoin('category.pictureTopCategory', 'pictureTopCategory') // table name

One time you are using table name, next you are using aliases !! Choose only one approach of them

After some research here in SO I came to this solution. Try adding

->from('YourEntityNameForP', 'p')
->from('YourEntityNameForShop', 'shop')

to createQueryBuilder

Since I'm not familiar neither with Symfony 2, nor with Doctrine 2 and just trying to help!

Credits here: Doctrine: Cannot select entity through identification variables without choosing at least one root entity alias