Advertisement
Guest User

Untitled

a guest
Feb 12th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.38 KB | None | 0 0
  1. def findOrder(id: Long, accountRequired: Boolean) = withSQL {
  2.   select
  3.     .from[Order](Order as o)
  4.     .innerJoin(Product as p).on(o.productId, p.id)
  5.     .map { sql =>
  6.       if (accountRequired) sql.leftJoin(Account as a).on(o.accountId, a.id) else sql
  7.     }.where.eq(o.id, 13)
  8.   }.map { rs =>
  9.     if (accountRequired) Order(o, p, a)(rs) else Order(o, p)(rs)
  10.   }.single.apply()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement