title: session.connection() is undefined for the type session in hibernate code
body: <p>I'm facing issue with session.connection() method is not accepted while hibernate upgrade done from hibernate 3.6 to hibernate 4.1.2..could you provide some solution for replace session.connection method?</p>
  
  <p>AuditLogInterceptor.java :</p>
  
  <pre><code>public class AuditLogInterceptor extends EmptyInterceptor{
  
      Session session;
      private Set inserts = new HashSet();
      private Set updates = new HashSet();
      private Set deletes = new HashSet();
  
      public void setSession(Session session) {   
          this.session=session;
      }
  
      public boolean onSave(Object entity,Serializable id,
          Object[] state,String[] propertyNames,Type[] types)
          throws CallbackException {
  
          System.out.println("onSave");
  
          if (entity instanceof IAuditLog){
              inserts.add(entity);
          }
          return false;
  
      }
  
      public boolean onFlushDirty(Object entity,Serializable id,
          Object[] currentState,Object[] previousState,
          String[] propertyNames,Type[] types)
          throws CallbackException {
  
          System.out.println("onFlushDirty");
  
          if (entity instanceof IAuditLog){
              updates.add(entity);
          }
          return false;
  
      }
  
      public void onDelete(Object entity, Serializable id, 
          Object[] state, String[] propertyNames, 
          Type[] types) {
  
          System.out.println("onDelete");
  
          if (entity instanceof IAuditLog){
              deletes.add(entity);
          }
      }
  
      //called before commit into database
      public void preFlush(Iterator iterator) {
          System.out.println("preFlush");
      }   
  
  
      //called after committed into database
      @SuppressWarnings("null")
      public void postFlush(Iterator iterator) {
          System.out.println("postFlush");
          TbMasUsers tmu = null;
          try{
  
              for (Iterator it = inserts.iterator(); it.hasNext();) {
                  IAuditLog entity = (IAuditLog) it.next();
                  System.out.println("postFlush - insert");
  
                  try {
  
                  AuditLogUtil.LogIt("Saved",entity, session.connection());
                      // session.doWork(entity);
                  } catch (HibernateException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }   
  
              for (Iterator it = updates.iterator(); it.hasNext();) {
                  IAuditLog entity = (IAuditLog) it.next();
                  System.out.println("postFlush - update");
                  try {
                      AuditLogUtil.LogIt("Updated",entity, session.connection());
                  } catch (HibernateException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }   
  
              for (Iterator it = deletes.iterator(); it.hasNext();) {
                  IAuditLog entity = (IAuditLog) it.next();
                  System.out.println("postFlush - delete");
                  try {
                      AuditLogUtil.LogIt("Deleted",entity, session.connection());
                  } catch (HibernateException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  } catch (Exception e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }   
  
          } finally {
              inserts.clear();
              updates.clear();
              deletes.clear();
          }
      }   
  
  }
  </code></pre>
  
  <h1>AuditLogUtil.java:</h1>
  
  <pre><code>public class AuditLogUtil{
  
  
      public static void LogIt(String action,
          IAuditLog entity, Connection conn) throws Exception{
          SessionServiceImpl sessionServiceImpl=new SessionServiceImpl();
          TbMasUsers tbMasUsers=(TbMasUsers) sessionServiceImpl.getUserInSession();
          Integer loingEmpId=Integer.parseInt(tbMasUsers.getIntEmpId().getStrEmpId());
  
          //SessionImpl sessionImpl = (SessionImpl) session;
          // Connection conn1 = sessionImpl.connection();
           Session tempSession = HibernateUtil.getSessionFactory().openSession(conn);
  
  
          try {
              @SuppressWarnings("null")
              AuditLog auditRecord = new AuditLog(action,entity.getLogDeatil()
                      , new Date(),entity.getId(), entity.getClass().toString(),loingEmpId);
              tempSession.save(auditRecord);
              tempSession.flush();
  
          } finally { 
              tempSession.close();    
  
          }
  
      }
  }
  </code></pre>