use of com.evolveum.midpoint.repo.sqlbase.JdbcSession in project midpoint by Evolveum.
the class TestSqaleRepositoryBeanConfig method clearDatabase.
/**
* Taken from `SqaleRepoBaseTest#clearDatabase()` - this is the new repo version of
* TestSqlRepositoryBeanPostProcessor.
* No need to clean up the cache tables, only the main and audit tables are cleared.
*/
public void clearDatabase(SqaleRepoContext sqlRepoContext) {
LOGGER.info("Postprocessing session factory - removing everything from database if necessary.");
try (JdbcSession jdbcSession = sqlRepoContext.newJdbcSession().startTransaction()) {
// Truncate cascades to sub-rows of the "object aggregate" - if FK points to m_object table hierarchy.
jdbcSession.executeStatement("TRUNCATE m_object CASCADE;");
// But truncate does not run ON DELETE trigger, many refs/container tables are not cleaned,
// because their FK references OID pool table. After truncating m_object_oid it cleans all the tables.
jdbcSession.executeStatement("TRUNCATE m_object_oid CASCADE;");
jdbcSession.executeStatement("TRUNCATE ma_audit_event CASCADE;");
jdbcSession.commit();
}
}
use of com.evolveum.midpoint.repo.sqlbase.JdbcSession in project midpoint by Evolveum.
the class AddObjectContext method execute.
/**
* Inserts the object provided to the constructor and returns its OID.
*/
public String execute() throws SchemaException, ObjectAlreadyExistsException {
try (JdbcSession jdbcSession = repositoryContext.newJdbcSession().startTransaction()) {
String oid = execute(jdbcSession);
jdbcSession.commit();
return oid;
} catch (QueryException e) {
// Querydsl exception, not ours
Throwable cause = e.getCause();
if (cause instanceof PSQLException) {
SqaleUtils.handlePostgresException((PSQLException) cause);
}
throw e;
}
}
Aggregations