Skip to content

Instantly share code, notes, and snippets.

@akr4
Created September 28, 2011 01:57
Show Gist options
  • Save akr4/1246801 to your computer and use it in GitHub Desktop.
Save akr4/1246801 to your computer and use it in GitHub Desktop.
// simple query
db.inTransaction { q =>
q.select("select * from emp") { row =>
User(row.id, row.name)
}
}
// many to one
dbinTransaction {
q => for(p <- q.select("select * from emp limit 3") { r =>
(r.string(2), r.manyToOne(3) { (q, id) =>
q.select("select * from dept where id = " + id) { r =>
r.string(2)
}
})
}) yield (p._1, p._2.get.toList.head)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment