These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Empty transaction generates SQL Statements
PostPosted: Wed Sep 08, 2004 1:51 pm 
Newbie

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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.