private function createRelation($entity)
    {
        $meta = $this->getMeta($entity);
        $pk = $meta->getPrimaryKey();
        $id = $pk->getValue($entity);

        $start = $meta->getStart()->getValue($entity);
        $end = $meta->getEnd()->getValue($entity);

        //If it already has an ID, get the relation from the DB
        if($id)
        {
            $relation = $this->client->getRelationship($id);

            //A start node was supplied
            if($start)
            {
                //Get the start node id
                $nid = $start->getId();

                //Check if the requested start node is different than the present one.
                if($nid != $relation->getStartNode()->getId())
                {
                    throw new Exception("You can't change the start node of a saved relation.");
                }

            }

            //A end node was supplied
            if($end)
            {
                //Get the end node id
                $nid = $end->getId();

                //If the attached nodes ID is different than the id the relation currently points to
                if($nid != $relation->getEndNode()->getId())
                {
                    throw new Exception("You can't change the end node of a saved relation.");
                }

            }

        }

        //Create a relationship with the correct type
        else
        {
            $relation = $this->client->makeRelationship()
                ->setType($meta->getName());

            //No start node
            if(!$start)
            {
                throw new Exception("No start node supplied for new " . $meta->getName() . " relation.");
            }

            //No end node
            if(!$end)
            {
                throw new Exception("No end node supplied for new " . $meta->getName() . " relation.");
            }

            //Set the nodes
            $relation->setStartNode($start)->setEndNode($end);
        }

        //Copy all the properties
        foreach ($meta->getProperties() as $property)
        {
            $result = $property->getValue($entity);

            $relation->setProperty($property->getName(), $result);
        }

        $currentDate = $this->getCurrentDate();

        //Set the creation date if this relation didn't exist
        if(!$id)
        {
            $relation->setProperty('creationDate', $currentDate);
        }

        //Set the update time
        $relation->setProperty('updateDate', $currentDate);

        return $relation;
    }