- This topic has 1 reply, 1 voice, and was last updated 19 years, 3 months ago by slepit.
-
AuthorPosts
-
slepitMemberHi,
I have a weird behaviour with hibernate.
Inserts are working fine, but updates are stange.
I update an object, flush it via hibernate.
If I check the database, the changes are made.Then when I check the result on my browser, I get the new data. But if I refresh several times, sometimes I get the old data.
i am using hibernate version 3.0
My HibernateUtil
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;public class HibernateUtil {
//private static Log log = LogFactory.getLog(HibernateUtil.class);
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory
//sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory = new Configuration().configure(“/hibernateJobMySql.cfg.xml”).buildSessionFactory();
} catch (Throwable ex) {
//log.error(“Initial SessionFactory creation failed.”, ex);
throw new ExceptionInInitializerError(ex);
}
}public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}}
The Save() of my object :
public void save() throws HibernateException, SQLException {
Session session = HibernateUtil.currentSession();
session.save(this);
session.flush();
}Any Idea why this is happening?
Please reply soon
slepitMemberSorry I am using MyEclipse v4 milestone 2 and hibernate 2.1
-
AuthorPosts