mirror of https://github.com/apache/openjpa.git
fix random failing behaviour if id did already exist
This commit is contained in:
parent
4e59c48364
commit
64af85106a
|
@ -119,9 +119,16 @@ public class TestSetParameter extends SingleEMFTestCase {
|
|||
public void testNativeSQL() {
|
||||
EntityManager em = emf.createEntityManager();
|
||||
em.getTransaction().begin();
|
||||
|
||||
// make sure that the ID we want to insert does not exist.
|
||||
int proposedId;
|
||||
do {
|
||||
proposedId = (int) System.currentTimeMillis() % 10000;
|
||||
} while (em.find(Address.class, proposedId) != null);
|
||||
|
||||
int count = em.createNativeQuery("INSERT INTO Address (id, city,"
|
||||
+ " country, streetAd, zipcode) VALUES (?,?,?,?,?)")
|
||||
.setParameter(1, System.currentTimeMillis()%10000)
|
||||
.setParameter(1, proposedId)
|
||||
.setParameter(2, "Some City")
|
||||
.setParameter(3, "Some Country")
|
||||
.setParameter(4, "Some Street")
|
||||
|
|
Loading…
Reference in New Issue