slick-2.0

How to use DateTime in Slick2.0?

情到浓时终转凉″ 提交于 2019-12-01 15:08:14
问题 I want to use DateTime in Slick 2.0 model. I use jodatime: I added the dependencies in Build.scala : "joda-time" % "joda-time" % "2.3", "org.joda" % "joda-convert" % "1.6" I then do: class Comment(tag:Tag) extends Table[(Long, Int, Int, String, Int, DateTime)](tag,"Comment"){ def id=column[Long]("ID", O.PrimaryKey) def rate=column[Int]("rate") def sub=column[Int]("subject") def content=column[Int]("cotent") def user_ID=column[Int]("user") def time=column[DateTime]("time") //-----------an

Slick: dynamic sortBy in a query with left join

两盒软妹~` 提交于 2019-12-01 10:39:48
This is a problem derived from another question . I need to be able to dynamically pass a column to be sorted on in a Slick query which has a left join. The problem in this particular situation is that left joined table becomes optional and I have no idea how to handle that. If I make table Company not optional I'm getting SlickException: Read NULL value for ResultSet column Path Example: def list(filter: String, orderBy: Int) = { DB.withDynSession { val data = for { (computer, company) <- Computer.where(_.name like filter) leftJoin Company on (_.companyId === _.id) } yield (computer, company.

Slick: dynamic sortBy in a query with left join

这一生的挚爱 提交于 2019-12-01 08:36:46
问题 This is a problem derived from another question. I need to be able to dynamically pass a column to be sorted on in a Slick query which has a left join. The problem in this particular situation is that left joined table becomes optional and I have no idea how to handle that. If I make table Company not optional I'm getting SlickException: Read NULL value for ResultSet column Path Example: def list(filter: String, orderBy: Int) = { DB.withDynSession { val data = for { (computer, company) <-

How to do “OR” filter in slick

只愿长相守 提交于 2019-11-30 18:28:25
In slick we can use query.filter( m => (m.state === state1 && m.status === status1) || (m.state === state2 && m.status == status2)) for an "OR" condition in where clause. However my requirement is I have "OR" conditions in a list (passed by user as part of URL). Conditions list includes tuples of state and status like List[(state1, status1),(state2, status2),(state3, status3)] So what I wanted was to either be able to build the || statement inside of filter so that I can use each of the conditions from the list to generate the query but I am not sure how to achieve that. Or if there is

Slick 2.0 Generic CRUD operations

試著忘記壹切 提交于 2019-11-26 20:03:58
问题 I've been looking around on how to implement a generic trait for commons CRUD and other kinds of operations, I looked at this and this and the method specified are working well. What I would like to have is a generic method for insertion, my class looks like this at the moment (non generic implementation): object CampaignModel { val campaigns = TableQuery[Campaign] def insert(campaign: CampaignRow)(implicit s: Session) = { campaigns.insert(campaign) } } What I tried so far, following the