title: GetgeneratedKeys not working although row inserted
body: <p>I use HSQLDB - Tried version 2.3.4 and 2.4.</p>
  
  <p>I have this Java code:</p>
  
  <pre><code>            String sqlquery = "MERGE INTO bewertung pu USING "
              .concat("(VALUES ?,?,?) ")
              .concat("temp (tid,jurorid,runde) ")
              .concat("ON temp.tid = pu.tid and temp.jurorid=pu.jurorid and temp.runde=pu.runde ")
              .concat("WHEN NOT MATCHED THEN ")
              .concat("INSERT (tid,jurorid,runde) ")
              .concat("VALUES (temp.tid,temp.jurorid,temp.runde)");
  
          PreparedStatement preparedStatement = sql.getConnection().prepareStatement(sqlquery,
                                        Statement.RETURN_GENERATED_KEYS);            
  
  
          preparedStatement.setInt(1, eineBewertung.getTanzID()); //TID
          preparedStatement.setInt(2, eineBewertung.getJurorID()); //JURORID
          preparedStatement.setInt(3, eineBewertung.getRunde()); //RUNDE
  
          int rowsAffected = preparedStatement.executeUpdate();           
  
          if (rowsAffected == 0) {
              //UPDATE
              //DO SOMETHING
          }else{
              //INSERT
              try (ResultSet rs = preparedStatement.getGeneratedKeys()) {
                 if (rs.next()) {      
                     eineBewertung.setBewertungsid(rs.getInt(1));
                 }
              }catch (SQLException ex) {
                  this.controller.error_ausgeben(ex);
              }
          }   
  </code></pre>
  
  <p>It works. If I insert a new row I get <code>rowsAffected</code> = 1. I check the database and the insert worked.</p>
  
  <p>But, I do not get anything back in the resultset <code>getGeneratedKeys()</code>
  It is every time empty.</p>
  
  <p>I have found some tips to replace <code>Statement.RETURN_GENERATED_KEYS</code> with the primary key. But this didn`t work for me.</p>
  
  <pre><code>    PreparedStatement preparedStatement = sql.getConnection().prepareStatement(sqlquery,
                                    new String[]{"BEWERTUNGSID"});
  </code></pre>
  
  <p>This is how I create the table:</p>
  
  <pre><code>            statement.execute("create table PUBLIC.BEWERTUNG"
                  .concat("(BEWERTUNGSID INTEGER IDENTITY,")
                  .concat("TID INTEGER FOREIGN KEY REFERENCES Tanz(Tanzid),")
                  .concat("JURORID INTEGER not null FOREIGN KEY References JUROR(JURORID),")  
                  .concat("RUNDE INTEGER not null,")
                  .concat("primary key(BEWERTUNGSID)")
                  .concat(")"));  
  </code></pre>
  
  <p>Why do I not get any generated keys back? Thank you</p>
  
  <p>//EDIT
  If I replace my sqlquery with an insert statement it is working.</p>
  
  <pre><code>            sqlquery = "INSERT INTO BEWERTUNG(TID, JURORID, RUNDE) VALUES(22, 2, 2)";    
  </code></pre>
  
  <p>Why is <code>merge</code> not working in the sqlquery?</p>