2013-01-15 38 views
0

用下面的DB脚本:斯卡拉ANORM选择查询

# Tasks schema 

# --- !Ups 

CREATE TABLE HashToUrl (
    hash integer, 
    url varchar(255) 
); 

# --- !Downs 

DROP TABLE HashToUrl; 

...为什么我得到这个错误:

[NoSuchElementException: key not found: hash]

...这种方法

def getTask(hash: Int): String = DB.withConnection { implicit c => 
    val result = SQL(
     """ 
     select count(*) as url from HashToUrl where hash={hash} 
     """ 
    ).apply().head 
    val url = result[String]("url") 
    url 
} 

回答