public function getLastInsertID() {
		if (count($this->rows) > 0) {
			$end = end($this->rows);
			if ($end->toRow() && $end->toRow()->getPrimary()) {
				return (int) $end->toRow()->getPrimary();
			} else if ($end->toRow() === NULL) {
				return NULL;
			} else {
				throw new RepositoryException("Table \"" . self::TABLE . "\" does not have a primary key.");
			}
		} else {
			return NULL;
		}
	}