New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Testaction does not handle transactions #244

Closed
gucce opened this Issue May 24, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@gucce
Contributor

gucce commented May 24, 2017

Problem

Citrus supports the execution of sql statements based on sql scripts. This can be accomplished as follows:

<sql datasource="my-ds">
    <resource file="classpath:lion/sql/insert_testdata.sql"/>
</sql>

With insert_testdata.sql (Oracle SQL):

SET TRANSACTION NAME 'testdata';
INSERT ...
INSERT ...
INSERT ...
COMMIT;

The problem is that citrus will execute every line within the script separately with a getJdbcTemplate().execute(stmt); call (see code). Depending on the configured DataSource this will not support the transaction and always execute and commit every statement. For example, a org.springframework.jdbc.datasource.DriverManagerDataSource will create a new connection for every execute invocation, thus preventing the transaction. The DriverManagerDataSource, however, does support transactions but this must be accomplished using a Spring transaction manager. At the moment this is not supported in Citrus.

Solution

Support Spring transaction managers. Add a section on transactions in the Citrus documentation.

@christophd christophd added this to the v2.7.2 milestone May 28, 2017

@christophd christophd added the READY label May 28, 2017

@christophd christophd added IN PROGRESS and removed READY labels Jun 30, 2017

@christophd christophd self-assigned this Jun 30, 2017

@christophd christophd closed this in a5410c8 Jul 4, 2017

@christophd christophd removed the IN PROGRESS label Jul 4, 2017

@gucce

This comment has been minimized.

Contributor

gucce commented Sep 21, 2017

I've just tried it. It works with a data source of type org.springframework.jdbc.datasource.DataSourceTransactionManager.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment