user3687679
user3687679

Reputation: 359

Complex Ebean Query

i am trying to make ebean query for this case: i want to filter users based on their last_update_time and update_frequency(in days) the query should get the users when last_update_time.plusDays(update_frequency)<now().

my query now looks like this:

List<User> users = Ebean.find(User.class).where().lt("last_update_time",DateTime.now()).findList(); 

i need to add update_frequency to the last_update_time. any idea how to do this?

Upvotes: 1

Views: 232

Answers (1)

Rob Bygrave
Rob Bygrave

Reputation: 4021

If last_update_time.plusDays(update_frequency)<now() ... is valid SQL (for your DB) then you can just pass that in via the "raw" expression. query.where().raw(...) like:

  List<User> users =
  Ebean.find(User.class)
    .where()
      .lt("last_update_time",DateTime.now())
      .raw("last_update_time.plusDays(update_frequency)<now()")
      .findList()

Upvotes: 1

Related Questions