Reputation: 958
Can anybody please tell me how to handle a transaction rollback in squeryl explicitly?
And also how can we add or remove columns in squeryl dynamically?
Thanx...
Upvotes: 2
Views: 757
Reputation: 3102
Just to elaborate a bit on the response from @didierd. There is one Session/Connection bound to each transaction. You can access the current Session, and thereby the Connection with code like:
Session.currentSession.connection
Or, if you're not sure if you're within a transaction
Session.currentSessionOption map {_.connection}
If you do roll back the transaction this way it will be your responsibility to start a new one or make sure there is no further use of the connection, so use with care.
Upvotes: 5
Reputation: 29538
You have an access to the JDBC's java.sql.Connection
(connection
in Session
), so if you really cannot use transaction
/ inTransaction
, you can call rollback there.
With access to the connection, you can also execute arbitrary SQL requests and so change the database schema, but be mindful that your squeryl-using code has a static, compile time known schema.
Upvotes: 1