With the following DB script:
# Tasks schema
# --- !Ups
CREATE TABLE HashToUrl (
hash integer,
url varchar(255)
);
# --- !Downs
DROP TABLE HashToUrl;
... why do I get this error:
[NoSuchElementException: key not found: hash]
... for this method
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
}
your code doesn't contain anything that will substitute the hash variable into the format string.
here are some very simple anorm examples to help you see what to do:
https://github.com/dustingetz/orm-deep-dive/blob/master/app/models/Environment.scala
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.