Skip to content

Instantly share code, notes, and snippets.

@emedina
Created May 17, 2011 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emedina/976653 to your computer and use it in GitHub Desktop.
Save emedina/976653 to your computer and use it in GitHub Desktop.
groovy> import es.coftal.dominio.*
groovy> def u = new Usuario(login:'emedina1', password:'sldkslkdlks')
groovy> try {
groovy> Usuario.withTransaction { status ->
groovy> status.transaction.sessionHolder.session.writeConcern = com.mongodb.WriteConcern.SAFE
groovy> try {
groovy> u.save(flush:true,failOnError:true)
groovy> }
groovy> catch (e) {
groovy> println "CAUGHT EXCEPTION!!!!!! = " + e
groovy> }
groovy> }
groovy> }
groovy> catch (e) {
groovy> println "CAUGHT EXCEPTION IN TX!!!!!!! = " + e
groovy> }
CAUGHT EXCEPTION!!!!!! = org.springframework.dao.DataIntegrityViolationException: E11000 duplicate key error index: cOftal.usuario.$login_1 dup key: { : "emedina1" }; nested exception is com.mongodb.MongoException$DuplicateKey: E11000 duplicate key error index: cOftal.usuario.$login_1 dup key: { : "emedina1" }
CAUGHT EXCEPTION IN TX!!!!!!! = org.springframework.transaction.TransactionSystemException: Could not commit Datastore transaction; nested exception is org.springframework.dao.DataIntegrityViolationException: E11000 duplicate key error index: cOftal.usuario.$login_1 dup key: { : "emedina1" }; nested exception is com.mongodb.MongoException$DuplicateKey: E11000 duplicate key error index: cOftal.usuario.$login_1 dup key: { : "emedina1" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment