If you get a SqlUpdate and change set its SQL more than once it can use the wrong sql.
That is, SqlUpdate is designed around using a single SQL statement ... but the api allows you to change the SQL and hence use it in a way not intented.
SqlUpdate sqlUpdate = Ebean.createSqlUpdate();sqlUpdate.setSql("insert into mytable ... ");sqlUpdate.setParameter(...)sqlUpdate.setParameter(...)sqlUpdate.execute();
sqlUpdate.setSql("insert into anothertable");sqlUpdate.setParameter(...)sqlUpdate.setParameter(...)sqlUpdate.execute();
Suggestion from Eddie:
...we can just pass the sql to the create method
SqlUpdate update = ebeanServer.createSqlUpdate("Insert into Person...");
... and remove the setSql() method.
Will break some code but then you don't have this problem anymore and an update's sql is immutable.
Makes sense... the only problem is that would clash with the existing "named" update method.
However, long term your suggestion sounds a lot better to me... hmmm ...
... could perhaps change it to:
createNamedSqlUpdate(String)createSqlUpdate(String)
... and do the same for the SqlQuery side:
createNamedSqlQuery(String)createSqlQuery(String)
Certainly makes more sense than the current api. Hopefully we wouldn't be breaking too much existing code.