You can create a new Repository where ever you want, but it's recommended to create them in a seperate Repository folder.
While you could name the Repository file and class as you wish, it's recommended to name the Repository EntityNameRepository, to that you could quickly find those in your folder.
Let's assume we have an Project Entity, stored in AppBundle\Entity, it would look like this:
The important part here is the line @ORM\Entity(repositoryClass="AppBundle\Repository\ProjectRepository"), because it connects this Entity with the given Repository class.
Also you need to use the \Doctrine\ORM\Mapping class to use the mapping options.
The repository itself is pretty simple
It's important to notice that the Repository class must extend the \Doctrine\ORM\EntityRepository, so that it can work properly. Now you can add as many functions for different querys as you want.
ExpressionBuilder IN() function
If you want to use the MySQL command IN() in the QueryBuilder, you can do it with the in() function of the ExpressionBuilder class.
Make a Query with a Sub-Query
As example, only for demonstrate HOW-TO use a subquery select statement inside a select statement, suppose we what to find all user that not yet have compile the address (no records exists in the address table):
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0