use of io.vertigo.database.sql.connection.SqlConnection in project vertigo by KleeGroup.
the class SearchManagerStoreTest method doTearDown.
/**
* {@inheritDoc}
*/
@Override
protected void doTearDown() throws Exception {
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
// A chaque fin de test on arréte la base.
final SqlConnection connection = dataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
execCallableStatement(connection, "shutdown;");
transaction.commit();
}
}
use of io.vertigo.database.sql.connection.SqlConnection in project vertigo by KleeGroup.
the class SearchManagerStoreTest method doSetUp.
@Override
protected void doSetUp() throws Exception {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
// A chaque test on recrée la table famille
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
final SqlConnection connection = dataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
execCallableStatement(connection, "create table car(ID BIGINT, MAKE varchar(50), MODEL varchar(255), DESCRIPTION varchar(512), YEAR INT, KILO INT, PRICE INT, CONSOMMATION NUMERIC(8,2), MOTOR_TYPE varchar(50), OPTIONAL_NUMBER BIGINT, OPTIONAL_STRING varchar(50) );");
execCallableStatement(connection, "create sequence SEQ_CAR start with 10001 increment by 1");
}
// On supprime tout
remove("*:*");
final CarDataBase carDataBase = new CarDataBase();
carDataBase.loadDatas();
initialDbCarSize = carDataBase.size();
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
for (final Car car : carDataBase.getAllCars()) {
car.setId(null);
storeManager.getDataStore().create(car);
}
transaction.commit();
}
waitIndexation();
}
use of io.vertigo.database.sql.connection.SqlConnection in project vertigo by KleeGroup.
the class AbstractTaskEngineSQL method obtainConnection.
/**
* Retourne la connexion SQL de cette transaction en la demandant au pool de connexion si nécessaire.
* @return Connexion SQL
*/
private SqlConnection obtainConnection() {
final VTransaction transaction = transactionManager.getCurrentTransaction();
SqlConnection connection = transaction.getResource(getVTransactionResourceId());
if (connection == null) {
// On récupère une connexion du pool
// Utilise le provider de connexion déclaré sur le Container.
connection = getConnectionProvider().obtainConnection();
transaction.addResource(getVTransactionResourceId(), connection);
}
return connection;
}
use of io.vertigo.database.sql.connection.SqlConnection in project vertigo by KleeGroup.
the class AbstractSqlDataBaseManagerTest method doSetUp.
@Override
protected final void doSetUp() throws Exception {
final SqlConnection connection = obtainMainConnection();
try {
execpreparedStatement(connection, createTableMovie());
execpreparedStatement(connection, createSequenceMovie());
if (commitRequiredOnSchemaModification()) {
connection.commit();
}
} finally {
connection.release();
}
}
use of io.vertigo.database.sql.connection.SqlConnection in project vertigo by KleeGroup.
the class AbstractSqlDataBaseManagerTest method testSelectListInput.
@Test
public void testSelectListInput() throws Exception {
// On crée les données
createDatas();
// ----
final SqlConnection connection = obtainMainConnection();
final List<Movie> movies;
final List<Movie> moviesParams = new ArrayList<>();
moviesParams.add(Movies.createMovie(1, Movies.TITLE_MOVIE_1, null, null, null, null, null, null, null));
moviesParams.add(Movies.createMovie(2, Movies.TITLE_MOVIE_2, null, null, null, null, null, null, null));
try {
movies = dataBaseManager.executeQuery(SqlStatement.builder("select * from movie where movie.title in (#movies.0.title#, #movies.1.title#) ").bind("movies", List.class, moviesParams).build(), Movie.class, 2, connection);
} finally {
connection.release();
}
Assert.assertEquals(2, movies.size());
}
Aggregations