public function setUsername($username)
    {
        if($username == $this->username){
            return true;
        }
        if ($this->usernameExists($username)) {
            return false;
        }

        if ($this->setUsernameStatement === null) {
            $this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?");
        }
        $wasLoggedIn = $this->isLoggedIn();

        $this->setUsernameStatement->execute(array($username, $this->username));
        $this->username = $username;

        if ($wasLoggedIn) {
            $this->updateLoginSession();
        }
        $this->notifyObservers(User::EVENT_USERNAME_UPDATE);
        return true;
    }