title: Resetting auto-increment value of MySql database with JPA
body: <p>I just started out writing my first unit tests with JUnit and I ran into a small problem.
  Inside my unit-tests i'm inserting new data into my MySql database. After I added my info, I delete that same info in the next unit test.</p>
  
  <p>My table-id is auto-incrementing and with each unit-test I run the value for the next id is incremented with 1.</p>
  
  <p>I implemented a new method with the @AfterClass annotation so that after I'm done with my unit-tests it will reset the increment value. I used this query:</p>
  
  <pre><code>entityManager.createNativeQuery("ALTER TABLE student AUTO_INCREMENT = 1");
  </code></pre>
  
  <p>If I add new info directly into my MySql database the value of the next id isn't what I want it to be (last id value in my table +1).</p>
  
  <p>However when I run the sql-query directly in the database, the query does work. </p>
  
  <p>My question: Is it impossible to run these kind of queries while unit-testing? Or am I totally looking at this the wrong way.</p>
  
  <p>I'm using java, spring, hibernate, jpa , junit</p>
  
  <p>Thanks in advance!</p>