Version: Hibernate 3.0.5/3.0.4,
I can't save my data into database when only use session.flush(), actually, when I run the programe in DEBUG mode and DEBUG it step by step, I can see that there is one record which has been inserted into my tables, but when DEBUG was terminated, the record I saw before had been deleted as well.(there is no error messages)
CODE 1 -- Without persist data
===========================================================
Session session = HibernateSession.currentSession();
Long generatedId = (Long) session.save(v);
session.flush();
===========================================================
But In another hand, everything goes fine when I use a transatcion to commit().
CODE 2 -- It's Ok now
===========================================================
Session session = HibernateSession.currentSession();
Transaction tx = session.beginTransaction();
Long generatedId = (Long) session.save(v);
session.flush();
tx.commit();
===================================================
So, I don't wanna to begin a transaction in my application, what can i do? I haven't meet these problems in Hibernate 2. Thanks very much.
PS: I run my code without an application server, and my development tool is Websphere Studio Application Developer V5.1
Best Regards,
|