On Fri, Feb 26, 2010 at 2:10 PM, harryh har...@gmail.com wrote:
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
}
}
}
Looks cool. As you note, this should probably be abstracted for each DbProvider.
/Jeppe
--
You received this message because you are subscribed to the Google Groups
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.