title: Hibernate HQL delete with and
body: <p>Hibernate doesn't delete my row:</p>
  
  <pre><code>public boolean deleteVote(Login user, int pid){
  
        Session session = getSession();
  
        try{
            String hql = "delete from Vote where uid= :uid AND pid= :pid";
            Query query = session.createQuery(hql);
            System.out.println(user.getUid() + " and pid: " + pid);
            query.setString("uid", user.getUid());
            query.setInteger("pid", pid);
            System.out.println(query.executeUpdate());
        }catch(Exception e){
  </code></pre>
  
  <p>Outprint:</p>
  
  <pre><code>uid: 123 and pid: 1
  Hibernate: delete from votes where uid=? and pid=?
  1
  </code></pre>
  
  <p>The SQL Syntax is working when I'm trying directly in SQL. Direct SQL Syntax:</p>
  
  <pre><code> delete from votes where uid= '123' AND pid= 1
  </code></pre>
  
  <p>Mapping:</p>
  
  <pre><code>&lt;class name="package.model.Vote" table="votes"&gt;
     &lt;id name="vid" column="vid" &gt;
     &lt;generator class="increment"/&gt;
  &lt;/id&gt;
  &lt;property name="pid" column="pid" /&gt;
  &lt;property name="uid" column="uid" /&gt;
  &lt;property name="tid" column="tid" /&gt;
  &lt;property name="votes" column="votes" /&gt;
   &lt;/class&gt;
  </code></pre>
  
  <p>Table:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `votes` (
    `vid` int(11) NOT NULL 
    `pid` int(11) NOT NULL,
    `uid` varchar(20) NOT NULL,
    `tid` int(11) NOT NULL,
    `votes` int(11) NOT NULL DEFAULT '1',
    PRIMARY KEY (`vid`),
    KEY `pcid` (`pid`,`uid`),
    KEY `uid` (`uid`),
    KEY `tid` (`tid`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
  
  ALTER TABLE `votes`
  ADD CONSTRAINT `votes_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `poll` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `votes_ibfk_4` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON     UPDATE CASCADE,
  ADD CONSTRAINT `votes_ibfk_5` FOREIGN KEY (`tid`) REFERENCES `teams` (`tid`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  INSERT INTO `votes` (`vid`, `pid`, `uid`, `tid`, `votes`) VALUES
  (20, 1, '123', 1, 1);
  </code></pre>
  
  <p>I guess it's something pretty easy because everything looks okay for me so far. I got no error or anything else, just that no delete is happening.</p>
  
  <p>Any help is appreciated.</p>