java - Play Framework Ebean query retreival -
i want show previous 5 transactions of signed in user in banking app.
public static model.finder<string,transaction> find = new model.finder<string,transaction>(string.class,transaction.class); public static list<transaction> fetchtransactions (string currentuser) { return find.where().eq("user.username",currentuser).setmaxrows(5).findlist(); }
i tried ebean.find function:
@inject list<transaction> list = ebean.find(transaction.class).fetch("transnature").fetch("amount").where().eq("user.username",user.findbyemail(request().username()).username).findlist();
what doing wrong?
if want last 5 transactions, have include order respective column, transactiondate descending order. otherwise ebean default, fetch rows order id in ascending order. first 5 rows transaction table.
try this,
public static list<transaction> fetchtransactions(string currentuser) { return find.where().eq("user.username",currentuser).orderby("transactiondate desc").setmaxrows(5).findlist(); }
Comments
Post a Comment