i am trying to integrate circumflex-orm into a play-2.0 scala app. It works so far as i can retrieve and save elements into db.
What does not work is the cache handling – transaction management.
For instance, retrieve a list of objects, change one, store it into db works fine.
But if i retrieve the same list again, my object did not change.
It did not change in the meaning of, it did change in the database, but the cache doesn’t know anything about it.
I did post a question at the circurmflex group and they said they do it with a servletfilter (this is the actual code for it: (circumflex-orm transaction integration – look at main lifecycle).
Something like this would be enough:
class CircumflexContextFilter extends ServletFilter {
import ru.circumflex.core._
def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) {
Context.executeInNew { ctx =>
chain.doFilter(req, res)
}
}
}
But i have no idea how to integrate this into a play 2.0 application.
Thanks in Advance,
Sven
It turned out to be easier than i thought, a guy at the irc (thanks noelw) pinpointed me to these docs: scala action composition
Reading through that the answer is as easy as possible:
First, write your own action class like this:
And then call your actions like this:
Thats it. I also wrote i blop post for the integration of circumflex-orm into play, if anyone is interested: integrate circumflex-orm in play 2.0 – scala