slick

implicit conversion of RESULTSET for queries

蓝咒 提交于 2019-12-11 06:57:33
问题 I'm using Scala 2.10 and have problems with Slick (plain queries, java.sql.ResultSet). If I write queries like Q.query[String, ResultSet](query).list(rs.getString("id")) eclipse will tell me could not find implicit value for parameter rconv: scala.slick.jdbc.GetResult[java.sql.ResultSet] My most important source for this issue ( http://slick.typesafe.com/doc/0.11.2/sql.html ) does not help. How do I write these implicit conversions? And is there any other, familar way of representing

Slick 3.1.x CRUD: how to extract the inserted row id?

纵饮孤独 提交于 2019-12-11 06:18:08
问题 I have the following coupled-to-model DAO implementation and to persist a new entity in the database I do (note the extra steps to be able to fetch the serially generated id) and this compiles fine (not actually tested yet): // this is generated by the Slick codegen case class UserRow(id: Long, ... class User(_tableTag: Tag) extends Table[UserRow](_tableTag, "user") lazy val User = new TableQuery(tag => new User(tag)) // function to persist a new user def create(user: UserRow): Future[UserRow

How to do I pass TableQuery as a Generic and then use it?

主宰稳场 提交于 2019-12-11 06:05:29
问题 I'm trying to template-out a TableQuery member but the path dependant types are messing me up. I've got a typical code-generated table like so: trait TablesContainer { case class MembersRow(firstName:String, lastName:String) class Members(_tableTag: Tag) extends Table[MembersRow](_tableTag, Some("dbo"), "MEMBERS") { def * = (firstName, lastName) <> (MembersRow.tupled, MembersRow.unapply) val firstName: Rep[String] = column[String]("FIRM_NAME") val lastName: Rep[String] = column[String]("LAST

How to create entity relationships in slick?

末鹿安然 提交于 2019-12-11 05:32:22
问题 I am working in a project with scala play 2 framework where i am using slick as FRM and postgres database. In my project customer is an entity. So i create a customer table and customer case class and object also. Another entity is account. The code is given bellow case class Customer(id: Option[Int], status: String, balance: Double, payable: Double, created: Option[Instant], updated: Option[Instant]) extends GenericEntity { def this(status: String, balance: Double, payable: Double) = this

on slick 2.0, I find I can not store user defined field

微笑、不失礼 提交于 2019-12-11 04:16:45
问题 I use slick 2.0 rc I have defined field UserId: case class UserId(id: Long) extends AnyVal with BaseId object UserId extends IdCompanion[UserId] when I use it: class Resources(tag: Tag) extends Table[Resource](tag, "RESOURCE") { def id = column[Long]("ID", O.PrimaryKey, O.AutoInc) def owner = column[UserId]("Owner") def types = column[String]("Type") def withuser = foreignKey("User_FK", owner, Users)(_.id) it give me compile error as: [error] C:\assigment\slick-advanced\app\models\Resource

ERROR!! AppGameContainer java.lang.ClassNotFoundException

别说谁变了你拦得住时间么 提交于 2019-12-11 04:09:01
问题 this is my code: import org.newdawn.slick.*; import org.newdawn.slick.state.*; public class Game extends StateBasedGame{ public static final String gamename = "Ham Blaster!"; public static final int menu = 0; public static final int play = 1; public Game(String gamename) { super(gamename); this.addState(new Menu(menu)); this.addState(new Play(play)); } public void initStatesList(GameContainer gc) throws SlickException{ this.getState(menu).init(gc, this); this.getState(play).init(gc, this);

Exception when insert records into 3 tables within transaction using slick-plain SQL for play2

那年仲夏 提交于 2019-12-11 03:36:50
问题 My scenario is as below: There are 3 tables (user, security, password) in my PG DB. When the end use tries to register self into my database, the code will check if the use exists in the user table. If exists, just return a None. otherwise, insert records into (user, security, password) within the same transaction. The following is my code: def selectUserCountQuery1(user: User): DBIO[Int] = { sql"""SELECT COUNT(user_id) FROM users WHERE provider_id = ${user.providerId} AND phone_num = ${user

How to 'create temp table as select' in Slick?

拟墨画扇 提交于 2019-12-11 03:17:46
问题 Is there any way to create a temp table from a select statement in Slick without using a plain sql query? I looked through the docs and was unable to find how to create a temp table, so I'm not sure if it's possible. 回答1: It appears that this is not supported yet. Slick's github shows it as an open issue: https://github.com/slick/slick/issues/799 来源: https://stackoverflow.com/questions/29981529/how-to-create-temp-table-as-select-in-slick

Returning the auto incrementing value after an insert using slick

 ̄綄美尐妖づ 提交于 2019-12-11 03:16:01
问题 I am using slick 2.0.1 (and can upgrade if required) and I want to retrieve the auto incrementing value from the database (postgresql). I have seen a few questions on SO on this already, but they are fairly old and I was hoping there was a better way than to do what this answer suggests: Scala & Play! & Slick & PostgreSQL auto increment def autoInc = name ~ price ~ description returning id def add(product: Product)(implicit s:Session): Long = { Products.autoInc.insert(p.name, p.price, p

How to join two tables and map the result to a case class in slick

假如想象 提交于 2019-12-11 03:07:24
问题 I am working in a project with scala play 2 framework where i am using slick as FRM and postgres database. In my project customer is an entity. So i create a customer table and customer case class and object also. Another entity is account. So i create a account table and account case class and object also. The code is given bellow case class Customer(id: Option[Int], status: String, balance: Double, payable: Double, created: Option[Instant], updated: Option[Instant]) extends GenericEntity {