I am a bit bewildered about how to best use the new getCurrentSession functionality of SessionFactory. I currently manage the current session myself using thread local storage and it works nicely, but I would rather use Hibernate supplied functionality and rely on SessionFactory rather than my own wrapper around it.
1) You say it is best to use JTA. Yet it seems like I have to waste time learning yet another api, and relying on yet another framework for very little gain. Apparently I will also have to choose between various implementations that will tie me into that implementation. Essentially it sounds preferable to jump without a parachute.
2) Then there is the ThreadLocalSessionContext. Looking at the javadoc it seems like I can't use multiple SessionFactories in my webapp. How do I check if a transaction is open during cleanup so I can commit it without creating a new session?
3) Implement my own CurrentSessionContext. Seems like my only option, but how do I plug it in to the SessionFactory?
Henrik
|