Skip to content

Instantly share code, notes, and snippets.

@MinCha
Created February 10, 2015 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MinCha/59e001fbffb5e916e52c to your computer and use it in GitHub Desktop.
Save MinCha/59e001fbffb5e916e52c to your computer and use it in GitHub Desktop.
My Function Class #2
@Component class InTransaction {
@Transactional def execute[T](f: => T): T = f
}
object InTransaction {
def apply[T](f: => T): T = Global.ctx.getBean(classOf[InTransaction]).execute(f)
}
def findListByUserMatching(): EssentialAction = UserAction { user =>
request =>
InTransaction {
val popularQuestion = questionService.findPopularQuestion.get
val result = questionService.findListByUserMatching(user).map(new MatchQuestionListView(_))
success(result, new PopularQuestionView(popularQuestion))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment