Fixed SQL to match ebean special behaviour