History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: EJB-83
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Vance Karimi
Reporter: Olivier THIERRY
Votes: (View)
Watchers: (View)
Operations

If you were logged in you would be able to see more operations.
EJB Cartridge

No way to distinguish NoResultException from other exceptions when you call a DAO query method

Created: 24/Aug/07 05:21 PM   Updated: 11/Mar/08 10:11 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Text File patch-ejb-83.txt (1 kb)
2. Text File returnNullIfNoResultException_patch.txt (2 kb)

Environment: AndroMDA 3.3-SNAPSHOT + EJB3 cartridge


 Description   
There's something wrong in the way DAOs query method are generated with EJB3 cartridge. All exceptions thrown by Query are wrapped in a DaoException, including NoResultException. So that when you call a DAO method and it throws an exception, you have no easy way to know if the exception is thrown because there is no result (which could be something expected) or because there is an error in the request, a problem with the database, etc ... It would be better to do like Hibernate cartridge does : if there is no result for the query, the method returns null. For other exceptions, it throws an exception.

 All   Comments   Change History      Sort Order:
Comment by Olivier THIERRY [27/Aug/07 02:41 PM]
Vance, I wrote this patch. Please tell me if you think it is OK.

Comment by Olivier THIERRY [11/Mar/08 10:11 AM]
There was an error with the patch I supplied : it worked with a SELECT query but not with an UPDATE one. The code catching NoResultException was generated for both kinds of queries so I had a compilation failure with "return null". I added a new patch to generate NoResultException catch code only for select queries and no more for update ones.