Recently I tried to use Squeak and MySQL. The Jdm classes that I pulled down from package universe got me connected just fine but there was no transaction support in the Jdm code. I wanted to begin, commit and rollback transactions. I added this behavior by doing the following.
1) I added this code to my subclass of JdmConnection in the class initialize method. This makes it so the Jdm infrastructure will allow you to execute a query that starts with these phrases (START, COMMIT, ROLLBACK).
JdmFactory40 instance queries at: 'START' put: #(#update); at: 'COMMIT' put: #(#update); at: 'ROLLBACK' put: #(#update); yourself. JdmFactory41 instance queries at: 'START' put: #(#update); at: 'COMMIT' put: #(#update); at: 'ROLLBACK' put: #(#update); yourself
2) I created helper methods on my JdmConnection subclass to actually do the begin, commit and rollback:
begin self createStatement executeQuery: 'BEGIN'. rollback self createStatement executeQuery: 'ROLLBACK'. commit self createStatement executeQuery: 'COMMIT'.
I ended up not using MySQL (not yet) because I decided to just use some cheap xml persistence until our business outgrows it. But, I’m sure I will eventually end up using this code again.