/**
 * Validate that the primary key has been set.
 *
 * @return  boolean  True if the primary key(s) have been set.
 *
 * @since   3.1.4
 */
public function hasPrimaryKey()
{
    if ($this->_autoincrement) {
        $empty = true;
        foreach ($this->_tbl_keys as $key) {
            $empty = $empty && empty($this->{$key});
        }
    } else {
        $query = $this->_db->getQuery(true)->select('COUNT(*)')->from($this->_tbl);
        $this->appendPrimaryKeys($query);
        $this->_db->setQuery($query);
        $count = $this->_db->loadResult();
        if ($count == 1) {
            $empty = false;
        } else {
            $empty = true;
        }
    }
    return !$empty;
}