Sent this to dpp the other day with the idea that it might be a useful
addition to MetaMapper. Would others find this useful? (It's a tad
PostgreSQL specific in its current form).
object LockMode extends Enumeration {
type LockMode = Value
val AccessShare = Value("ACCESS SHARE")
val RowShare = Value("ROW SHARE")
val RowExclusive = Value("ROW EXCLUSIVE")
val ShareUpdateExclusive = Value("SHARE UPDATE EXCLUSIVE")
val Share = Value("SHARE")
val ShareRowExclusive = Value("SHARE ROW EXCLUSIVE")
val Exclusive = Value("EXCLUSIVE")
val AccessExclusive = Value("ACCESS EXCLUSIVE")
}
import LockMode._
trait Lockable[T <: Mapper[T]] extends MetaMapper[T] {
self: T =>
def lock[T](mode: LockMode)(func: => T) = {
DB.use(dbDefaultConnectionIdentifier) { conn =>
DB.statement(conn)(_.execute("LOCK TABLE "+dbTableName+" IN
"+mode.toString+" MODE"))
func
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.