clean up remaining test suite failures

- stored procedure parameters - oracle
This commit is contained in:
Steve Ebersole 2022-01-20 10:35:39 -06:00
parent 45d5dc8e74
commit fa9ab7bdae
1 changed files with 16 additions and 46 deletions

View File

@ -39,7 +39,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.NamedStoredProcedureQueries; import jakarta.persistence.NamedStoredProcedureQueries;
import jakarta.persistence.NamedStoredProcedureQuery; import jakarta.persistence.NamedStoredProcedureQuery;
@ -457,60 +456,31 @@ public class OracleStoredProcedureTest {
@AfterEach @AfterEach
public void cleanUpSchema(EntityManagerFactoryScope scope) { public void cleanUpSchema(EntityManagerFactoryScope scope) {
EntityManager entityManager = scope.getEntityManagerFactory().createEntityManager(); scope.inEntityManager( (em) -> {
entityManager.getTransaction().begin(); final Session session = em.unwrap( Session.class );
try {
Session session = entityManager.unwrap( Session.class );
session.doWork( connection -> { session.doWork( connection -> {
try (Statement statement = connection.createStatement()) { try (Statement statement = connection.createStatement()) {
statement.executeUpdate( "DROP PROCEDURE sp_count_phones" ); statement.executeUpdate( "DROP PROCEDURE sp_count_phones" );
}
catch (SQLException ignore) {
}
} );
}
finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
entityManager = scope.getEntityManagerFactory().createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap( Session.class );
session.doWork( connection -> {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate( "DROP PROCEDURE sp_person_phones" ); statement.executeUpdate( "DROP PROCEDURE sp_person_phones" );
} statement.executeUpdate( "DROP PROCEDURE singleRefCursor" );
catch (SQLException ignore) { statement.executeUpdate( "DROP PROCEDURE outAndRefCursor" );
} statement.executeUpdate( "DROP PROCEDURE sp_phone_validity" );
} ); statement.executeUpdate( "DROP PROCEDURE sp_votes" );
}
finally {
entityManager.getTransaction().rollback();
entityManager.close();
}
entityManager = scope.getEntityManagerFactory().createEntityManager();
entityManager.getTransaction().begin();
try {
Session session = entityManager.unwrap( Session.class );
session.doWork( connection -> {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate( "DROP FUNCTION fn_count_phones" ); statement.executeUpdate( "DROP FUNCTION fn_count_phones" );
statement.executeUpdate( "DROP FUNCTION fn_person_and_phones" );
statement.executeUpdate( "DROP FUNCTION find_char" );
} }
catch (SQLException ignore) { catch (SQLException ignore) {
} }
} ); } );
}
finally { scope.inTransaction( em, (em2) -> {
entityManager.getTransaction().rollback(); final List<Person> people = em.createQuery( "from Person", Person.class ).getResultList();
entityManager.close(); people.forEach( em::remove );
}
scope.releaseEntityManagerFactory(); em.createQuery( "delete IdHolder" ).executeUpdate();
});
} );
} }
@NamedStoredProcedureQueries({ @NamedStoredProcedureQueries({