Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0 Final
-
Fix Version/s: 2.2.1
-
Component/s: Service Layer
-
Labels:None
-
Environment:Windows XP, tomcat 6, hibernate, MySQL 5.04
Description
after enabling lazyLoadingFilter, when updating an user (e.g. 'admin') with some value rejected by the DB (e.g. change 'admin' Username to already existing 'user' Username : the unique key on app_user.username fires an exception), the DB raw exception is displayed to the user instead of begin trapped.
When creating a new user, the exception is correctly handled.
seems that the entityManager.flush() is not raising the exception when updating e record + lazy loading enabled.
NB. the behaviour is exactly the same when using JPA instead of hibernate
how to reproduce
-> mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0 -DgroupId=a.group.id -DartifactId=test
-> cd test
-> change web/src/.../web.xml to enable lazyLoadingFilter as documented into web.xml
-> launch app under tomcat
-> edit user 'admin'
-> change Username to 'user'
I was able to reproduce it, but I don't know how to solve it. For some reason, a raw Hibernate exception (org.hibernate.exception.ConstraintViolationException) is being thrown and it's not wrapped by a Spring exception. Since this exception is not caught in UserManagerImpl and re-wrapped as a UserExistsException, the error does not display as expected. I don't want to put logic in UserManagerImpl that catches this exception because it's specific to Hibernate.
If you find a solution, I'd love to hear about it. In the meantime, I'm moving this issue to the next release.