Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails transactions (not GORM based but using Groovy Sql)
    primarykey
    data
    text
    <p>My Grails application is not using GORM but instead uses my own SQL and DML code to read and write the database (The database is a huge normalized legacy one and this was the only viable option).</p> <p>So, I use the Groovy Sql Class (<a href="http://groovy.codehaus.org/api/groovy/sql/Sql.html" rel="nofollow">http://groovy.codehaus.org/api/groovy/sql/Sql.html</a>) to do the job. The database calls are done in Services that are called in my Controllers.</p> <p>Furthermore, my datasource is declared via DBCP in Tomcat - so it is not declared in Datasource.groovy.</p> <p>My problem is that I need to write some transaction code, that means to open a transaction and commit after a series of successful DML calls or rollback the whole thing back in case of an error.</p> <p>I thought that it would be enough to use <a href="http://groovy.codehaus.org/api/groovy/sql/Sql.html#commit()" rel="nofollow">http://groovy.codehaus.org/api/groovy/sql/Sql.html#commit()</a> and <a href="http://groovy.codehaus.org/api/groovy/sql/Sql.html#rollback()" rel="nofollow">http://groovy.codehaus.org/api/groovy/sql/Sql.html#rollback()</a> respectively.</p> <p>But in these methods Javadocs, the Groovy Sql documentation clearly states </p> <blockquote> <p>If this SQL object was created from a DataSource then this method does nothing.</p> </blockquote> <p>So, I wonder: What is the suggested way to perform transactions in my context? Even disabling autocommit in Datasource declaration seems to be irrelevant since those two methods "...do nothing"</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload