title: Duplicate entry Exception while generating UUID in Liquibase changeset
body: <p>I'm using a Liquibase changeset to update <code>null</code> values of the <code>customId</code> column. The sql is a modified version of <a href="https://stackoverflow.com/a/11397626/184792">this answer</a>.</p>
  
  <p>The problem is that it seems to use the same UUID for all rows. My changeset looks like this:</p>
  
  <pre><code>&lt;changeSet id="v3.0.3" author="msp" runAlways="false"&gt;
      &lt;preConditions onFail="MARK_RAN"&gt;
          &lt;not&gt;
              &lt;sqlCheck expectedResult="0"&gt;select count(*) from FOOBAR where customId is null&lt;/sqlCheck&gt;
          &lt;/not&gt;
      &lt;/preConditions&gt;
  
      &lt;sql&gt;update FOOBAR set customId = concat('cu:', (select uuid())) where customId is null&lt;/sql&gt;
  &lt;/changeSet&gt;
  </code></pre>
  
  <p>Note that if I'm running this slightly modified version of the query (adding a limit of 2) in the MySQL console, then it works:</p>
  
  <p><code>update FOOBAR set customId = concat('cu:', (select uuid())) where customId is null limit 2</code> </p>
  
  <p>But if I try to run the very same query (including the limit) with liquibase, I get the following Exception:</p>
  
  <pre><code>Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set changelog/db.changelog-v3.0.3.xml::v3.0.3::msp:
       Reason: liquibase.exception.DatabaseException: Error executing SQL update FOOBAR set customId = concat('cu:', (select uuid())) where customId is null limit 2: Duplicate entry 'cu:cde325da-f71f-11e5-95f8-d15a50829a7d' for key 'customId'
      at liquibase.changelog.ChangeSet.execute(ChangeSet.java:554)
      at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43)
      at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:70)
      at liquibase.Liquibase.update(Liquibase.java:195)
      at liquibase.Liquibase.update(Liquibase.java:174)
      at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:330)
      at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:287)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
      ... 77 more
  Caused by: liquibase.exception.DatabaseException: Error executing SQL update FOOBAR set customId = concat('cu:', (select uuid())) where customId is null limit 2: Duplicate entry 'cu:cde325da-f71f-11e5-95f8-d15a50829a7d' for key 'customId'
      at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
      at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
      at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1206)
      at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1189)
      at liquibase.changelog.ChangeSet.execute(ChangeSet.java:518)
      ... 85 more
  Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'cu:cde325da-f71f-11e5-95f8-d15a50829a7d' for key 'customId'
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
      at com.mysql.jdbc.Util.getInstance(Util.java:386)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2677)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2627)
      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:841)
      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
      at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)
      at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:310)
      at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
      ... 89 more
  </code></pre>
  
  <p>Note that there's of course a <code>UNIQUE</code> constraint on <code>customId</code> - but shouldn't <code>select uuid()</code> (also tried <code>uuid()</code> without select) generate a unique value, even when using Liquibase?</p>