disable test for databases which cannot handle large PKs

On MariaDB and MySQL the allowed size of compound primary keys is very limited.
This very test will not work with them. It's nothing JPA can heal, users
are restricted and have to work around it.
This commit is contained in:
Mark Struberg 2021-04-03 16:08:56 +02:00
parent 8d3acdc11e
commit 495fe202a3
1 changed files with 162 additions and 155 deletions

View File

@ -35,8 +35,8 @@ public class TestRelationFieldAsPrimaryKeyAndForeignKey
setUp(C.class, CM.class, D.class, E.class, VC.class,
VCS.class, CLEAR_TABLES);
EntityManager em = emf.createEntityManager();
try {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
List<E> es = (List<E>) em.createQuery(
"Select e from E e").getResultList();
@ -45,9 +45,6 @@ public class TestRelationFieldAsPrimaryKeyAndForeignKey
em.getTransaction().commit();
em.close();
} catch (Exception e) {
}
em = emf.createEntityManager();
em.getTransaction().begin();
@ -87,7 +84,15 @@ public class TestRelationFieldAsPrimaryKeyAndForeignKey
em.getTransaction().commit();
em.close();
} catch (Exception e) {
if (e.getMessage().contains("max key length")) {
// on MariaDB the keys are too long
setTestsDisabled(true);
}
}
}
public void testUnboundEntities() {
EntityManager em = emf.createEntityManager();
@ -197,6 +202,7 @@ public class TestRelationFieldAsPrimaryKeyAndForeignKey
@Override
public void tearDown() throws Exception {
if (!isTestsDisabled()) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
List<E> es = (List<E>) em.createQuery(
@ -207,6 +213,7 @@ public class TestRelationFieldAsPrimaryKeyAndForeignKey
em.getTransaction().commit();
em.close();
}
super.tearDown();
}
}