I have some problems with the changed commit behavior in
Hibernate 3.1 rc1. I already read
http://www.hibernate.org/42.html
and I think its much easier for most applications.
However one of our benchmarks now needs 4x more
time.
We are using the a session-per-conversation pattern.
With hibernate.current_session_context_class="thread".
Thus our session is closed on each commit !
That very different from the behavior in hibernate <= 3.1 b3.
It looks like I can alter this behaviour using my own
implementation of CurrentSessionContext. I didnt try this
so far.
Our benchmark worked like this using a stateful session:
Code:
Transaction tx = session.beginTransaction();
Query q = session.createQuery(<someQuery>);
ScrollableResults users = q.scroll();
int cnt = 0;
while( users.next() ) {
User user = (User) users.get(0);
user.updateUser();
if (++cnt % objectsPerTA == 0) {
session.flush();
tx.commit();
session.clear();
tx.begin();
}
}
In 3.1rc1 after commit the session is closed and tx.begin() does not work anymore. Opening a new session doesnt work either, since the cursor query is connected to the old session and is broken too.
Creating two sessions one for read and one for write gives a concurrent
data access exception on large numbers of objects.
Committing just once at the end of the loop works but is four times slower.
So an implementation of CurrentSessionContext will probably solve this problem. And certainly a stateless session would be the best solution.
Perhaps someone else has similar problems.