Created
September 28, 2011 01:57
-
-
Save akr4/1246801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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