| Problem: 
Hibernate is executing an Update statement after a commit is called on a criteria.list()
 
 Any ideas why this happens?
 
 I call a commit since the code inside the try can change to a saveOrUpdate() or delete().
 
 Hibernate version:
 Hibernate 3
 
 Code between sessionFactory.openSession() and session.close():
 try
 
 ......
 
 session = HibernateUtils.currentSession();
 HibernateUtils.beginTransaction();
 if (criteria_collection != null) {
 Criteria criteria = session.createCriteria(entityClass);
 
 for (Criterion crit: criteria_collection) {
 criteria.add(crit);
 }
 
 result = criteria.list();
 } else {
 result =
 session.createQuery(" from " + entityClass.getName()).list();
 }
 
 .......
 
 HibernateUtils.commitTransaction();
 } catch (Throwable t) {
 log.error("Unexpected error!", t);
 HibernateUtils.rollbackTransaction();
 } finally {
 HibernateUtils.closeSession();
 }
 
 Name and version of the database you are using:
 Oracle 10g
 
 The generated SQL (show_sql=true):
 06/04/21 12:14:57 Hibernate: select passwordpo0_.IDPASSWORDPOLICY as IDPASSWO1_0_, passwordpo0_.DCREATE as DCREATE0_, passwordpo0_.DMODIFY as DMODIFY0_, passwordpo0_.IDCREATEUSER as IDCREATE4_0_, passwordpo0_.IDMODIFYUSER as IDMODIFY5_0_, passwordpo0_.NEXPIREDAYS as NEXPIRED6_0_, passwordpo0_.NMINCHARS as NMINCHARS0_, passwordpo0_.SZALLOWEDLETTERS as SZALLOWE8_0_, passwordpo0_.NMINLETTERS as NMINLETT9_0_, passwordpo0_.SZALLOWEDDIGITS as SZALLOW10_0_, passwordpo0_.NMINDIGITS as NMINDIGITS0_, passwordpo0_.SZALLOWEDSYMBOLS as SZALLOW12_0_, passwordpo0_.NMINSYMBOLS as NMINSYM13_0_, passwordpo0_.SZUNALLOWEDPASSWORDS as SZUNALL14_0_, passwordpo0_.NALLOWEDATTEMPTS as NALLOWE15_0_, passwordpo0_.NOLDPASSWORDSCOUNT as NOLDPAS16_0_, passwordpo0_.NUNLOCKINMINUTES as NUNLOCK17_0_ from PASSWORDPOLICY passwordpo0_
 
 06/04/21 12:14:57 Hibernate: update PASSWORDPOLICY set DCREATE=?, DMODIFY=?, IDCREATEUSER=?, IDMODIFYUSER=?, NEXPIREDAYS=?, NMINCHARS=?, SZALLOWEDLETTERS=?, NMINLETTERS=?, SZALLOWEDDIGITS=?, NMINDIGITS=?, SZALLOWEDSYMBOLS=?, NMINSYMBOLS=?, SZUNALLOWEDPASSWORDS=?, NALLOWEDATTEMPTS=?, NOLDPASSWORDSCOUNT=?, NUNLOCKINMINUTES=? where IDPASSWORDPOLICY=?
 _________________
 Regards,
 Alexander Kamburov
 
 wise_guybg at yahoo.com
 
 
 |