Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate Data not updating in database
    primarykey
    data
    text
    <p>I am using hibernate 3 in my application there is one scenario where i am inserting two record and updating one record :-</p> <pre><code> SessionFactory sf = HibernateUtils.getSessionFactory(); session = sf.openSession(); tx = session.beginTransaction(); Collection collection = session.load(Collection.class, "12345"); tx.commit(); // using this way i am getting this object from database. setCollection(collection);//Here i am setting this object in one POJO class </code></pre> <p>Now in other function </p> <p>I am getting this object again...</p> <pre><code>Collection collection=getCollection(); //here it is detached </code></pre> <p>Now here first i am saving data in one table using below approach:-</p> <pre><code> SessionFactory sf = HibernateUtils.getSessionFactory(); session = sf.openSession(); tx = session.beginTransaction(); Sms sms=new Sms(); sms.setMessage(collection.getMesage()); session.save(sms); tx.commit(); session.flush(); session.close(); </code></pre> <p>Then i am updating and inserting two records in same session</p> <pre><code>SessionFactory sf = HibernateUtils.getSessionFactory(); session = sf.openSession(); tx = session.beginTransaction(); Cancel cancel=new Cancel(); cancel.setMessage(collection.getMesage()); session.save(cancel); session.update(collection); tx.commit(); session.flush(); session.close(); </code></pre> <p>The problem in above code , Here in sms and in cancel table data is saving but update is not working and it is not showing any error also.</p> <p>Its not happening in every case, sometime it is not updating</p> <p>Is there any problem with two different sessions ??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload