Q:

Query language in Play Framework 2

How do I select from a table by another unique column other than id
im looking a replacement for 
     String fbid=<some facebookId>
     User user = User.findBy("facebookId",fbid).first();

I'm using Java + Ebean and not scala! 
thanks

A:

User user = User.find.where().eq("facebookId", fbid).findUnique();

Of course you can create a 'shortcut' by adding a method into your User model:
public static User findByFacebookId(String fbid){
    return find.where().eq("facebookId", fbid).findUnique();
}

and using it in controller:
User user = User.findByFacebookId(fbid); 

It's pretty good solution as you can keep your controllers' code clean and use custom finders as sophisticated as required at the case. 

