Truncate Table And Insert data JAVA SPRING JPA

I have 2 transactions

1 – em.createNativeQuery( “TRUNCATE ” + myTable ).executeUpdate();

2 – Integer rowsAffected = em.createNativeQuery(“INSERT INTO myTable VALUES (‘1’, ‘1’, ‘kk’, ‘kk’, ’20’, ’20’, ‘2017-11-14’, ‘vh’, ’10’, ‘ul’,’0′);”).executeUpdate();

but i need to protect the data in case that the 2 instruction fail, and i must use truncate because drop don’t reset the id(PK) from the table so dont work for me
what i can do or use?

Im using

org.springframework 4.3.9.RELEASE

spring-data-jpa 1.11.3.RELEASE

JAVA 8

MYSQL