* This method fetches one object in read only mode and returns it's value object.
*/
protected BaseEntityVO getVOWithId(Class arg, Integer id, Database db, boolean retry) throws SystemException, Bug
{
IBaseEntity vo = null;
try
{
RequestAnalyser.getRequestAnalyser().incApproximateNumberOfDatabaseQueries();
vo = (IBaseEntity)db.load(arg, id, Database.READONLY);
}
catch(Exception e)
{
try
{
if(retry)
{
logger.info("Error getting object. Message: " + e.getMessage() + ". Retrying...");
vo = (IBaseEntity)getVOWithId(arg, id, db, false);
}
else
{
logger.info("Error getting object. Message: " + e.getMessage() + ". Not retrying...");
throw new SystemException("An error occurred when we tried to fetch the object " + arg.getName() + ". Reason:" + e.getMessage(), e);
}
}
catch(Exception e2)
{
throw new SystemException("An error occurred when we tried to fetch the object " + arg.getName() + ". Reason:" + e.getMessage(), e);
}
}
finally
{
RequestAnalyser.getRequestAnalyser().decApproximateNumberOfDatabaseQueries();
}
if(vo == null)
{
throw new Bug("The object with id [" + id + "] was not found. This should never happen.");
}
return vo.getVO();
}