title: How can I loop through Exception getCause() to find root cause with detail message
body: <p>I am trying to call <code>saveOrUpdate()</code> in hibernate to save data. Since columns have unique index, so its throws <code>ConstraintViolationException</code> when I look through via Eclipse debugger.  </p>
  
  <p>Since root cause could be different for different exception while inserting data to table.<br>
  I wanted to know, how can I loop / traverse through <code>getCause()</code> to check what is the root cause of exception and its message.</p>
  
  <p>Update:<br>
  Thanks everyone for your kind response, thing is I want output like in below image:<br>
  <img src="https://i.stack.imgur.com/n0Laj.png" alt="enter image description here"><br>
  I need to access  <strong>detailMessage</strong> field.<br>
  (I am really sorry If could not make my question more clear.)</p>
  
  <p>Thanks.</p>