Joined: Wed Sep 08, 2004 7:14 am Posts: 3 Location: Vienna, Austria
|
While debugging my application I made the following excpetionell discovery
An empty transaction (no code between session.beginTransaction() and
transaction.commit()) generates a delete statment on my oracle database.
in my opinion that doesnt make any sense independent of the state of the actual session, any other session or transactions or the state of other database transactions.
am i wrong?
Here is the code that is executing.
........
........
........
Transaction transaction = session.beginTransaction();
transaction.commit();
........
........
........
<p>
public class HibernateSession {
public static final ThreadLocal session = new ThreadLocal();
private static int no = 0; // used to identify a Session
public static final ThreadLocal serialNo = new ThreadLocal();
public static Session getSession()
throws NamingException, HibernateException {
Session s = (Session) session.get();
if (s == null)
{
SessionFactory sessionFactory = ZIVSServer.getHibernateConfiguration();
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static int getSerialNo()
{
Integer number = (Integer)serialNo.get();
if (number == null)
{ no++;
serialNo.set(new Integer(no));
}
return ((Integer)serialNo.get()).intValue();
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null) s.close();
}
}
</p>
|
|