Skip to content

Instantly share code, notes, and snippets.

View jsilva's full-sized avatar

Joao Da Silva jsilva

View GitHub Profile
@jsilva
jsilva / UserModel.scala
Created August 27, 2011 14:12
some snippet i found on the web. for Play Scala Anorm
package models
import externals.BCrypt
import play.db.anorm._;
class User (protected var _id: Int, protected var _email: String, protected var _name: String,
protected var _password: String, protected var _permissions: Set[String]) extends ActiveModel {
private val BCRYPT_WORK_FACTOR: Int = 6
case object transaction {
import java.sql.Connection
def apply[T](query: => T):Option[T] = {
val conn:Connection = play.db.DB.getConnection
val auto:Boolean = conn.getAutoCommit
try {
conn.setAutoCommit(false)
Some(query)
} catch {