Skip to content

Instantly share code, notes, and snippets.

@lucascs
Created April 5, 2011 16:13
Show Gist options
  • Save lucascs/903913 to your computer and use it in GitHub Desktop.
Save lucascs/903913 to your computer and use it in GitHub Desktop.
Scala Active Record with DI
@Component
class ActiveRecord[T](session:Session) {
implicit def obj2AR(obj:T) = new AR(session, obj)
}
class AR[T](session:Session, obj:T) {
def save = session.save(obj)
}
@Resource
class ProductController(ar:ActiveRecord[Product]) {
import ar._
def save(product:Product) {
product.save
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment