Avatar para usuário
08/12/2011 05:36
0
Usei esse exemplo para colocar avatar para os usuários da minha app
Mudo o avatar dele a primeira vez e nao tem problema
Porem para mudar de novo acontece isso

Error 500: Executing action [uploadAvatar] of controller [UsuarioController] caused exception: Object of class [Usuario] with identifier [5]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Usuario#5]
Servlet: grails
URI: /App/grails/usuario/uploadAvatar.dispatch
Exception Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Usuario#5]
Caused by: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Usuario#5]
Class: UsuarioController
At Line: [44]
Tags: avatar


0
O que tem na linha 44 do controller é

usuarioInstance = usuarioInstance.merge()


que eu coloquei pq estava dando esse problema

Error 500: Executing action [uploadAvatar] of controller [UsuarioController] caused exception: a different object with the same identifier value was already associated with the session: [Usuario#5]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Usuario#5]
Servlet: grails
URI: /App/grails/usuario/uploadAvatar.dispatch
Exception Message: a different object with the same identifier value was already associated with the session: [Usuario#5]
Caused by: a different object with the same identifier value was already associated with the session: [UsuarioController#5]
Class: UsuarioController
At Line: [46]


a linha 46 é o save

if (!usuarioInstance.save(flush: true)) {
redirect(controller:'usuario', action:'create'
}

08/12/2011 05:45


0
E então...
Alguem sabe outra maneira de resolver esse problema ?

Exception Message: a different object with the same identifier value was already associated with the session: [Usuario#5]

pq com o usuarioInstance = usuarioInstance.merge()

eu pego outro erro

Exception Message: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [Usuario#5]
13/12/2011 18:46



Ainda não faz parte da comunidade???

Para se registrar, clique aqui.


Aprenda Groovy e Grails com a Formação itexto!

Newsletter Semana Groovy

Assinar

Envie seu link!


Livro de Grails


/dev/All

Os melhores blogs de TI (e em português) em um único lugar!

 
Creative Commons
RSS Grails Brasil é mantido por itexto Consultoria.
Em caso de problemas contacte Henrique Lobo Weissmann (Kico) por e-mail: kico@itexto.com.br
Todo o conteúdo presente neste site adota o Creative Commons como licença padrão.
Ver: 4.14.0
itexto