programming

More Scala + Hibernate / 2007-11-16

In a prior post on livejournal, I described a problem and partial solution to using Hibernate with Scala. When I left things, I said:

The only real downside to this is that it doesn't enforce that entities are used only in the context in which they were created. I'd love to find a way to solve this. I think it might be possible to recover this by parameterizing the entity types, binding the type parameter with a single unsafe-but-safe cast as they come out of the database, and then enforcing that the implicit Context parameter matches the type parameter. I'll have to experiment with this, although truth be told, I'm not sure this level of safety is worth the hassle.

So I've done this experiment.