Issue Details (XML | Word | Printable)

Key: APF-575
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Bryan Noll
Reporter: Michael Horwitz
Votes: 0
Watchers: 0
Operations

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

GenericDao should have an exists(id) method

Created: 16/Jan/07 03:13 AM   Updated: 05/Mar/07 01:14 PM   Resolved: 05/Mar/07 01:14 PM
Component/s: Persistence Layer
Affects Version/s: 2.0-M3
Fix Version/s: 2.0-M4


 Description  « Hide
Many applications have process flows that need to check for the existence/non-existence of a persistent instance of an entity. Although this is possible using the current generic dao, it requires a try/catch block around get(id) and will generate a warning message in the logs if no such persitent instance exists, which may not be desired. It would be more elegant, and make code significantly easier to read, if the dao had an additional exists(id) method:

Currently:

try {
  genericDao.get(id);
}
catch (ObjectRetrievalFailureException e)
{
  //Object does not exist
 .....
}

Note that in the above snippet ObjectRetrieval exception may be thrown in other cases too - not just when the object does not exist.

Proposed:

if ( !genericDao.exists(id) ) {
  //Object does not exist
  .........
}


Bryan Noll made changes - 16/Jan/07 08:53 AM
Field Original Value New Value
Assignee Matt Raible [ mraible ] Bryan Noll [ bnoll ]
Bryan Noll made changes - 05/Mar/07 12:15 PM
Fix Version/s 2.0-M4 [ 10130 ]
Affects Version/s 2.0-M3 [ 10112 ]
Affects Version/s 2.0-M2 [ 10005 ]
Bryan Noll made changes - 05/Mar/07 12:15 PM
Status Open [ 1 ] In Progress [ 3 ]
2547 by  Bryan Noll (2 files)
05/Mar/07 01:13 PM (41 months, 6 days ago)
Bryan Noll added a comment - 05/Mar/07 01:14 PM
Committed revision 2547

Bryan Noll made changes - 05/Mar/07 01:14 PM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]