14-07-2012, 01:53 PM
Un autre ORM :
package models
import org.squeryl.PrimitiveTypeMode._
import org.squeryl.{KeyedEntity, Schema}
import org.squeryl.annotations.Column
import org.squeryl.dsl._
import java.util.{Date}
import models.Db._
class User(
val id: Long,
@Column(length=40)
val login: String,
@Column(length=20)
val name: String,
@Column(length=6)
val color: String,
@Column("create_date")
val createDate: Date
) extends KeyedEntity[Long] {
lazy val squares: OneToMany[Square] = Db.userToSquares.left(this)
}
object User {
def findByLogin(login: String) =
from(users)(u =>
where(u.login === login)
select(u)
).headOption
}