String sql = "select * from ( " +
"select u.id as userId, earth_distance(ll_to_earth(" + latitude + ", " + longitude + "), ll_to_earth(c.latitude, c.longitude)) as distance " +
"from user u " +
"join city c on u.city_id = c.id " +
") s " +
"where distance <= 100000 " +
"order by distance";
SqlQuery query = Ebean.createSqlQuery(sql);
如何使用Ebean expressionList创建等效项? 我正在努力实现这样的目标:
ExpressionList<User> expressionList = Ebean.find(User.class)
.select("*, earth_distance(ll_to_earth(" + latitude + ", " + longitude + "), ll_to_earth(city.latitude, city.longitude)) as distance")
.where()
.lt("distance", maxDistance);
expressionList.orderBy("distance");
但未创建距离别名。