java - Variable transaction isolation levels by request -


i writing little auction app, , important bids recorded certainty. after all, last couple seconds of auction critical moments buyers, , can't risk them simultaneously bidding , having race condition.

and of course, that's transaction isolation for. can set isolation level serializeable, , we're set.

but other requests? if people viewing profiles, or sending messages, these requests don't need anywhere near kind of transaction isolation. read committed isolation level acceptable requests.

i'm setting transaction level part of hibernate property hibernate.connection.isolation, i'd able session.settransactionisolation(newisolation) per request.

session session = getsession(datasource, sessionfactory, connection.transaction_serializable);  public session getsession(datasource datasource, sessionfactory sessionfactory, int isolationlevel){    // connection current datasource , set new isolation   connection connectionwithnewisolation = datasource.getconnection();   connectionwithnewisolation.settransactionisolation(isolationlevel);    // session current sessionfactory new isolation   session session = sessionfactory.opensession(connectionwithnewisolation);    // hibernate 4.3   //sessionfactory.openstatelesssession(connection connection)   // hibernate 3.6   //sessionfactory.opensession(connection connection)   //sessionfactory.openstatelesssession(connection connection)    return session; } 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -