getting an error in Implementing authentication logic of signon controller

12 views
Skip to first unread message

ashok

unread,
Nov 12, 2012, 6:22:25 AM11/12/12
to scooter-...@googlegroups.com
hi friends, when i use this line for Implementing authentication logic
  ActiveRecord u = User.findFirst("username='" + username + "' and password='" + password + "'");  
( here User is the model ) 
in authenticate() method of SignonController.java of my project then i am getting a error in my command prompt like 
cannot find symbol : method findFirst(java.lang.String)
nd when i checked this method in given docs files in ( com.scooterframework.orm.activerecord.ActiveRecord ) then there is given this method findFirst() instead of findFirst(java.lang.String) but i prefer your twitterdemo example there is also use this line  
 ActiveRecord user = Account.findFirst("username='" + username + "' and password='" + password + "'");
( here Account is the model )
in authenticate() method of SignonController.java then that works proper so can you tell me why i am getting this error nd what i need to do for solving that error

John Chen

unread,
Nov 12, 2012, 9:34:26 AM11/12/12
to scooter-...@googlegroups.com
Ooops, the example was not updated along with scooter. I will do that later. That findFirst(String) API has been depreciated.

The current way of getting what you want is thru QueryBuilder as shown in the following code:
ActiveRecord user = User.limit(1).offset(0).where("username='" + username + "' and password='" + password + "'").getRecord();

As you can see, limit(1) and offset(0) will give you exactly the record which satisfies the where() condition. 

ashok

unread,
Nov 12, 2012, 12:23:11 PM11/12/12
to scooter-...@googlegroups.com
thank you so much it is working properly
Reply all
Reply to author
Forward
0 new messages