I just started object-oriented programming in Symfony 2, and I have a problem joining mysql tables. 

I have two tables:

**kommuner**:
id,name,capacity

**Activities**:
id,name,kommune\_id

*How do I join these tables in the entity files?*  

This is my function in DefaultController: 

```
public function aktiviteterAction()
{

    $em = $this->get('doctrine.orm.default_entity_manager');
    $aktiviteter = $em->getRepository(Aktiviteter::class)->findAll();

    return $this->render('default/aktiviteter.html.twig', [
        'aktiviteter' => $aktiviteter,
    ]);

}

```

and this is my entity, Kommune.php:

```
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Kommune
 */
class Kommune
{
 /**
 * @var integer
 */
private $id;

/**
 * @var string
 */
private $name;

/**
 * @var integer
 */
private $capacity;

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set name
 *
 * @param string $name
 * @return Kommune
 */
public function setName($name)
{
    $this->name = $name;

    return $this;
}

/**
 * Get name
 *
 * @return string 
 */
public function getName()
{
    return $this->name;
}

/**
 * Set capacity
 *
 * @param integer $capacity
 * @return Kommune
 */
public function setCapacity($capacity)
{
    $this->capacity = $capacity;

    return $this;
}

/**
 * Get capacity
 *
 * @return integer 
 */
public function getCapacity()
{
    return $this->capacity;
}
}

```

and this is my Aktiviteter.php entity:

```
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Aktiviteter
 */
class Aktiviteter
{
/**
 * @var integer
 */
private $id;

/**
 * @var string
 */
private $name;

/**
 * @var integer
 */
private $kommuneId;

/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set name
 *
 * @param string $name
 * @return Aktiviteter
 */
public function setName($name)
{
    $this->name = $name;

    return $this;
}

/**
 * Get name
 *
 * @return string 
 */
public function getName()
{
    return $this->name;
}

/**
 * Set kommuneId
 *
 * @param integer $kommuneId
 * @return Aktiviteter
 */
public function setKommuneId($kommuneId)
{
    $this->kommuneId = $kommuneId;

    return $this;
}

/**
 * Get kommuneId
 *
 * @return integer 
 */
public function getKommuneId()
{
    return $this->kommuneId;
}

/**
 * @ManyToOne(targetEntity="Kommune")
 * @JoinColumn(name="kommune_id", referencedColumnName="id")
 **/
private $kommune;

}

```

Can someone please explain how these table joins work in Symfony 2? I appreciate all kinds of help!