+
+       /**
+        * Find locations by user id
+        *
+        * @param $id The user id
+        * @return array The user locations
+        */
+       public function findByUserId($userId) {
+               //Get entity manager
+               $em = $this->getEntityManager();
+
+               //Get quote strategy
+               $qs = $em->getConfiguration()->getQuoteStrategy();
+               $dp = $em->getConnection()->getDatabasePlatform();
+
+               //Get quoted table names
+               //XXX: this allow to make this code table name independent
+               $tables = [
+                       'RapsysAirBundle:UserLocation' => $qs->getJoinTableName($em->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('locations'), $em->getClassMetadata('RapsysAirBundle:User'), $dp),
+                       'RapsysAirBundle:Location' => $qs->getTableName($em->getClassMetadata('RapsysAirBundle:Location'), $dp)
+               ];
+
+               //Set the request
+               $req = 'SELECT l.id, l.title
+FROM RapsysAirBundle:UserLocation AS ul
+JOIN RapsysAirBundle:Location AS l ON (l.id = ul.location_id)
+WHERE ul.user_id = :uid';
+
+               //Replace bundle entity name by table name
+               $req = str_replace(array_keys($tables), array_values($tables), $req);
+
+               //Get result set mapping instance
+               //XXX: DEBUG: see ../blog.orig/src/Rapsys/BlogBundle/Repository/ArticleRepository.php
+               $rsm = new ResultSetMapping();
+
+               //Declare result set for our request
+               $rsm->addEntityResult('RapsysAirBundle:Location', 'l');
+               $rsm->addFieldResult('l', 'id', 'id');
+               $rsm->addFieldResult('l', 'title', 'title');
+
+               //Send result
+               return $em
+                       ->createNativeQuery($req, $rsm)
+                       ->setParameter('uid', $userId)
+                       ->getResult();
+       }