Query Interface for delete query.
Query Interface for delete query.
implicit val session = AutoSession val (u, c) = (User.syntax("u"), User.column) withSQL { delete.from(User as u).where.eq(u.id, 1) }.update.apply() applyUpdate { delete.from(User).where.eq(c.id, 1) }
Query Interface for insert query.
Query Interface for insert query.
implicit val session = AutoSession val (u, c) = (User.syntax("u"), User.column) withSQL { insert.into(User).columns(c.id, c.name, c.createdAt).values(1, "Alice", DateTime.now) }.update.apply() applyUpdate { insert.into(User).values(2, "Bob", DateTime.now) }
Query Interface for select query.
Query Interface for select query.
implicit val session = AutoSession val u = User.syntax("u") val user = withSQL { select.from(User).where.eq.(u.id, 123) }.map(User(u.resultName)).single.apply() val userIdAndName = withSQL { select(u.result.id, u.result.name).from(User).where.eq.(u.id, 123) }.map(User(u.resultName)).single.apply()
Query Interface for update query.
Query Interface for update query.
implicit val session = AutoSession val u = User.syntax("u") withSQL { update(User as u).set(u.name -> "Chris", u.updatedAt -> DateTime.now).where.eq(u.id, 1) }.update.apply() applyUpdate { update(User as u).set(u.name -> "Dennis").where.eq(u.id, 1) }
Prefix object to avoid name confliction.
withSQL { QueryDSL.select.from(User as u).where.eq(u.id, 123) }