public function convertToDBValue($value, IConnector $connector) {
        if ($value === null) {
            $value = 'null';
        }
        else {
            $type = $this->mapping['type'];
            switch ($type) {
                case 'bool'   :
                case 'boolean': $value = $connector->escapeLiteral((bool) $value); break;

                case 'int'    :
                case 'integer': $value = (string)(int) $value; break;

                case 'real'   :
                case 'float'  :
                case 'double' : $value = (string)(float) $value; break;

                case 'string' : $value = $connector->escapeLiteral((string) $value); break;

                default:
                    if (is_class($type)) {
                        $value = (new $type())->convertToDBValue($value, $this, $connector);
                        break;
                    }
                    throw new RuntimeException('Unsupported type "'.$type.'" for database mapping of '.$this->entityMapping->getClassName().'::'.$this->getName());
            }
        }
        return $value;
    }