title: JPA 2.0 EclipseLink Check for unique
body: <p>I have a collumn as unique=true.. in Exam class....
  I found that because transactions are commited automaticaly so to force the commit i use 
  em.commit()</p>
  
  <p>However i would like to know how to check if it is unique.Running a query isnt a solution because  it may be an instert after checking because of the concurency....</p>
  
  <p>Which is the best way to check for uniqness?</p>
  
  <pre><code>List&lt;Exam_Normal&gt; exam_normals = exam.getExam_Normal();
      exam.setExam_Normal(null);
  
      try {
          em.persist(exam);
          em.flush();
  
          Long i = 0L;
          if (exam_normals != null) {
              for (Exam_Normal e_n : exam_normals) {
                  i++;
                  e_n.setItem(i);
                  e_n.setId(exam);
                  em.persist(e_n);
              }
          }
      } catch (Exception e) {
          System.out.print("sfalma--");
      }
  }
  </code></pre>
  
  <p>d</p>