Hi there!
I've been looking for a solution for this, on the Internet and in the board but I haven't found it so I'd really apreciate if anyone could give me any hint.
I need to make an application work with READ_UNCOMMITED isolation but it ignores that config (as the second transaction never reads uncommited data). The flow would be:
(I'm debugging the application to test it)
Step a) T1:Gets obj1
Step b) T1:Updates obj1
Step c) T2:Gets obj1
Step d) T1:commits changes to obj1.
hibernate.cfg.xml:
Code:
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/banco2</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
<property name="hibernate.connection.isolation">1</property>
Transaction1:
Code:
public static void main( String[] args )
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction trans = session.beginTransaction();
//Step a)
Cuentabancaria cuenta =(Cuentabancaria)session.get("com.josesa.hibernate.Cuentabancaria", new Integer(61));
//Step b)
cuenta.setDinero(new Float(cuenta.getDinero().floatValue()+100));
logger.debug(cuenta.getDinero());
//Step d)
trans.commit();
session.close();
}
Transaction 2:
Code:
public static void main( String[] args )
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction trans = session.beginTransaction();
//Step c)
Cuentabancaria cuenta =(Cuentabancaria)session.get("com.josesa.hibernate.Cuentabancaria", new Integer(61));
logger.debug(cuenta.getDinero());
trans.commit();
session.close();
}
I've done the same example
using plain JDBC and it works... any idea?? (BTW my DB is MySQL5)
Jose