View Full Version : Automatic exception translation for Roo-style Entity classes?
Aug 10th, 2009, 04:18 AM
I find the non-anemic entity model (that Roo generates by default via aspectj) very nice and simple. The one feature I miss from a repository-based approach, however, is the automatic translation of exceptions to the Spring dao exception hierarchy (using the appropriate bean post processor).
How do I go about enabling automatic exception translation with Roo-generated entities? Or do I simply have to type it in (via EntityManagerFactoryUtils) myself for each entity persistence method? =)
Aug 11th, 2009, 01:34 AM
This is an interesting point. We find there are users who want to leverage Spring's exception translation mechanisms and others who don't. But there is no reason why it should not be available for those who want to use it. So the easiest is to create a new command or amend a current (JPA-related) command to enable this feature.
The easiest way to support this would be if Roo would provide a small aspect which catches any RuntimeExceptions thrown by the JPA EntityManager and attempt to translate it accordingly.
I have raised a Jira ticket for this so you can track the work on it or even comment if you wish: ROO-182
Aug 12th, 2009, 03:06 AM
Thanks, I'll track ROO-182's development.
Feb 18th, 2010, 08:05 PM
I also tracked the roo-182 because i have a problem that when the there is no record to return, roo shows error in entitymanager.getSingleResult(); After i read in roo-182, i try to use command roo> install jpa exception -package ~.domain but in Roo 1.0.0 RC4 doesn't have this command. How should i do?
Feb 18th, 2010, 10:20 PM
Here's a link to ROO-182 (http://jira.springframework.org/browse/ROO-182) for everyone's convenience.
Apr 27th, 2011, 04:27 AM
ROO-182 says that this is implemented, but I can't find any docs that tell me how to disable exception translation in my entitites (or methods, if they must be on the entity for Roo to work). How do I go about this?
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.