| AWS SimpleDB doesn't support explicit transactional boundaries or isolation levels. There is no notion of |
| a commit or a rollback. There is some implicit support for atomic writes, but it only applies within the |
| scope of each individual item being written. |
| |
| However, simpledb plugin does batch up inserts |
| and updates until the session is flushed. This makes it possible to support some rollback options. |
| |
| You can use either transactional services or the static @withTransaction@ method. To mark a service as using the SimpleDB transaction manager, use the static @transactional@ property with the value @'simpledb'@: |
| |
| {code} |
| static transactional = 'simpledb' |
| {code} |
| |
| Alternately you can do ad-hoc transactions using the @withTransaction@ method: |
| |
| {code} |
| Person.withTransaction { status -> |
| new Person(firstName: "Bob").save() |
| throw new RuntimeException("bad") |
| new Person(firstName: "Fred").save() |
| } |
| {code} |
| |
| For example in this case neither @Person@ object will be persisted to the database, |
| because underneath the surface a persistence session is being used to batch up both insert |
| operations into a single insert. When the exception is thrown neither insert is ever |
| executed, hence we allow for some transactional semantics. |
| |
| |