Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I avoid Slick's model declaration verbosity and repetitiveness
    text
    copied!<p>I am currently using Slick 1.x to access MySQL within playframework 2.1.3. While generally Slick's features look pretty good, I cannot wrap my head around how repetitive the declaration syntax is. I mean have a look at the following code:</p> <pre><code>case class User (id: Option[Long] , firstName: String , lastName: String , email: String , password: String , status: String , createDate: Long = Platform.currentTime , firstLogin: Option[Long] , lastLogin: Option[Long] , passwordChanged: Option[Long] , failedAttempts: Int = 0 ) object User extends Table[User]("USER") { def id = column[Long]("id", O.PrimaryKey, O.AutoInc) def firstName = column[String]("firstName", O.NotNull) def lastName = column[String]("lastName", O.NotNull) def email = column[String]("mail", O.NotNull) def password = column[String]("password", O.NotNull) def status = column[String]("status", O.NotNull) def createDate = column[Long]("createDate", O.NotNull) def firstLogin = column[Long]("firstLogin", O.Nullable) def lastLogin = column[Long]("lastLogin", O.Nullable) def passwordChanged = column[Long]("passwordChanged", O.Nullable) def failedAttempts = column[Int]("failedAttempts", O.NotNull) def * = id.? ~ firstName ~ lastName ~ email ~ password ~ status ~ createDate ~ firstLogin.? ~ lastLogin.? ~ passwordChanged.? ~ failedAttempts &lt;&gt;(User.apply _, User.unapply _) def autoInc = * returning id } </code></pre> <p>It can't be right, that in order to have a simple case class and an access object, I will have to declare each and every field three times. Is there a way to avoid this error prone repetitiveness?</p> <p><strong>Update</strong>: Of course a solution to this problem should support read <strong>and write</strong> operations.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload