Spring Transaction Management

177 views
Skip to first unread message

StanAccy12

unread,
Sep 25, 2014, 9:15:49 AM9/25/14
to sq...@googlegroups.com
I just came across sql2o as a replacement for our existing Hibernate setup.  Am I correct in understanding that there's currently no support for Spring Transaction management (via @Transactional)?  If my understanding is correct on that point, is there anything in the 1.5.2 code base that would prevent me from creating my own Spring Transaction Manager implementation for sql2o - or is this required programmatic support something that was alluded to in the 2.0 discussion I read somewhere?

While we like the simplicity of sql2o (plain vanilla sql, useful auto-mapping of result sets and the custom mapping functionality), we do make heavy use of the @Transactional annotation in our projects, not only to ensure that transactions are handled correctly, to reduce the boilerplate around handling of them but also for unit testing (so that each test that hits a DB is automatically rolled back after execution).


Lars Aaberg

unread,
Sep 25, 2014, 4:33:21 PM9/25/14
to sq...@googlegroups.com

Hi,

I have not heard of any attempts of writing a Spring transactional manager for sql2o. I don't see why it should not be possible though!

Some of the stuff that will be included in sql2o 2.0, will probably make some types of extensions easier to make. I'm not sure what's required to make a spring transactional manager, so I don't know if that will be influenced.

If you succeed in making a spring transactional manager, would you be interested in sharing the code?

Regards
Lars Aaberg

25. sep. 2014 15:15 skrev "StanAccy12" <nbp...@gmail.com> følgende:
I just came across sql2o as a replacement for our existing Hibernate setup.  Am I correct in understanding that there's currently no support for Spring Transaction management (via @Transactional)?  If my understanding is correct on that point, is there anything in the 1.5.2 code base that would prevent me from creating my own Spring Transaction Manager implementation for sql2o - or is this required programmatic support something that was alluded to in the 2.0 discussion I read somewhere?

While we like the simplicity of sql2o (plain vanilla sql, useful auto-mapping of result sets and the custom mapping functionality), we do make heavy use of the @Transactional annotation in our projects, not only to ensure that transactions are handled correctly, to reduce the boilerplate around handling of them but also for unit testing (so that each test that hits a DB is automatically rolled back after execution).


--
You received this message because you are subscribed to the Google Groups "sql2o" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sql2o+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Pratt

unread,
Sep 25, 2014, 4:52:26 PM9/25/14
to sq...@googlegroups.com
Sure Ill share it - I have a good idea how to implement this, but Im running in to some problems hooking the Connection (hence my question about the package private constructor).

Since the SpringTransactionManager would be managing the commit/rollback, it also needs to manage the connection closing. I was trying to find a hook in to the existing classes so that I could override the close() method and throw an exception if a transaction was in process on the thread (or if the connection was being managed by the TXMgr).  

What I need ultimately is a way to obtain a Connection (either an existing one thats in-use due to transaction management or create a new one if this is the start of a new transaction) and then hook the Connection.close() so I can delay it until after the TXMgr has had a chance to issue commit or rollback.
Message has been deleted

adam.k...@gmail.com

unread,
Nov 14, 2017, 8:32:30 AM11/14/17
to sql2o
Did you manage to implement this?
Reply all
Reply to author
Forward
0 new messages