Sunday, September 13, 2009

Always call remove() after done using a dynamic view object

Always call VO.remove() after you are done using a dynamic view object:

ViewObject voobject = null;
try
{
voobject = mTransaction.createViewObjectFromQueryStmt("sql statement");
boolean exists = ( voobject.first() != null);
}
finally
{
voobject.remove();
}
Make sure to surround your VO.remove(); with finally.
If you don't, a java runtime exception could fire before you even get to your VO.remove().

No comments: