找不行

时间:2015-03-31 06:00:30

标签: grails gorm

为什么这个findBy方法不起作用?

def star(){
   print params.phone_number// print number 015658788 successfully

   def user = User.findByPhone_number(params.phone_number) //not working
   //def user = User.findByPhone_number("015658788") //working

   print user //print null

   if(user) {
      user.status=1
      println user.status
      user.save(flush:true)
   }
}

2 个答案:

答案 0 :(得分:1)

尝试:

def user = User.findByPhoneNumber(params.phone_number) 

答案 1 :(得分:0)

def user = User.findByPhoneNumber(Integer.parseInt(params.phone_number)) 

我想你正在使用Double

def user = User.findByPhoneNumber(Double.parseDouble(params.phone_number))