java - EBeans alternative to find() in JPA -
i following play! framework tutorial on creating blog. use jpa instead of ebeans , use find() function extend play.db.jpa.model . using ebeans , have extended play.db.ebean.model . however, when use find() function, says no such method exists. have done research , have looked here: http://www.playframework.com/documentation/2.0/api/java/play/db/ebean/model.html
and here: http://www.playframework.com/documentation/2.0/api/java/play/db/ebean/model.finder.html
but there no mention of simple find() method (there others such findid() don't see how can help). there alternative use in model class? if not, there other classes use easily?
edit:
the specific part need create connect() method in user class. in tutorial, described as:
in user.java source, add connect() method: public static user connect(string email, string password) { return find("byemailandpassword", email, password).first(); }
what other options have if can't use find(). ebean.find() work?
i aware of 2 methods of using find() method of play.db.ebean.model. first 1 goes this:
user user = ebean.find(user.class, id);
the second method this:
//define model.finder class in user model class //the first parameter datatype of id used, string in case public static model.finder<string,user> find = new model.finder<string,user>(string.class, user.class); user user = user.find.byid(id);
since query fetches data based on 2 values, code should this:
user.find.where() .eq("email", email).eq("password",password) .findunique();
Comments
Post a Comment