Here is Hibernate config file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.jnetdirect.jsql.JSQLDriver</property>
<property name="connection.url">jdbc:JSQLConnect://192.168.1.1:4433/database=MvsSite</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="hibernate.connection.isolation">1</property>
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">1000</property>
<property name="hibernate.c3p0.validate">false</property>
<mapping resource="com/avadhuta/stardragon/common/jdo/DeletedObject.hbm.xml"/>
<mapping resource="com/mvs/site/entity/News.hbm.xml"/>
<!-- and so on -->
</session-factory>
</hibernate-configuration>
I can't show exact code, because it very compicated and divided on several blocks. Here is main idea:
Code:
Session session=sessionFactory.createSession();
Transaction transaction;
try{
transaction=session.beginTransaction();
} catch(Exception ex){
session.close();
throw ex;
}
/////////////////////// do something clever //////////////////////////
boolean commit=true; // or false if was some problem like exception
try{
if(transaction.wasCommitted() == false && transaction.wasRolledBack() == false){
if(commit){
transaction.commit();
}else{
transaction.rollback();
}
}
}catch(Exception ex){
session.connection().rollback();
throw ex;
}finally{
session.close();
}
I have my own server-side program and Jetty web server as plugin module. Any operations on server go through this code to obtain access to database. And any operation use only one session. I think, problem consist in simultaneous access to table. When I add/update rows, some web-users can load a page, that show a content of this rows. I store binary data in my table, and it may take much time to complete transaction. (Maximum 1 second.)
I just suggested, that READ_UNCOMMITED isolation level make impossible to lock table in any way. But factual situation show, it was wrong idea.