protected function buildDataJoins()
    {
        $joins    = array('one' => array(), 'many' => array());
        $joinsUse = array();

        foreach ($this->config->getAllJoin() as $name => $join) {

            $config = $join['class'];

            if (!($config instanceof ConfigInterface)) {
                throw new \LogicException('Joined class is not an instance of ConfigInterface!');
            }

            $class = $config->getClassname();

            if ('one' === $join['type']) {
                $joinMethod = $this->buildDataJoinsOne($config, $join['keys']);
            } else {
                $joinMethod = $this->buildDataJoinsMany($config, $join['keys']);
            }
            $joins[$join['type']][] = $joinMethod;

            $joinsUse[$class] = 'use ' . $this->baseNamespace . 'Data\\' . $config->getNamespace() . '\\' . $class . ';';
            $joinsUse[$class . 'Mapper'] = 'use ' . $this->baseNamespace . 'Mapper\\' . $config->getNamespace() . '\\' . $class . 'Mapper;';

        }

        $this->vars['joins_use'] = implode("\n", $joinsUse);
        $this->vars['joins']     = implode("\n", $joins['one']) . "\n" . implode("\n", $joins['many']);
    }