Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had similar issue, In my situation there was a problem in the connection, obviously if no connection then no session, if no session no transaction. </p> <pre><code> try { session = HibernateSessionFactory.getSessionFactory() .openSession(); session.beginTransaction(); StringBuffer qry = new StringBuffer(); qry.append(" select a.customer_key from customer as a where a.name= '"+siteName+"' "); query = session.createSQLQuery(qry.toString()); customerList = (ArrayList) query.list(); session.getTransaction().commit(); } catch (HibernateException hex) { session.getTransaction().rollback(); String msg = "Error occured in getCustomerId Cause: " + hex; logger.error(msg); throw new DAOException(msg); }finally{ if(session != null){ session.close(); } } </code></pre> <p>In the above snippet a rollback occurs to a session that does not even exist. This resulted in Transaction not successfully started. So I added a nested try catch block to avoid this error.</p> <p>So my modified code looked something like this.</p> <pre><code>try { session = HibernateSessionFactory.getSessionFactory() .openSession(); session.beginTransaction(); StringBuffer qry = new StringBuffer(); qry.append(" select a.customer_key from customer as a where a.name= '"+siteName+"' "); query = session.createSQLQuery(qry.toString()); customerList = (ArrayList) query.list(); session.getTransaction().commit(); } catch (HibernateException hex) { try{ session.getTransaction().rollback(); }catch(Exception e){ //just log warn } String msg = "Error occured in getCustomerId Cause: " + hex; logger.error(msg); throw new DAOException(msg); }finally{ if(session != null){ session.close(); } } </code></pre>
    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.
    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