*
* @param item Item to reload
*/
protected void reloadItemAfterModelUpdate(Item item)
{
PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
try
{
DbModelItem dbModelItem = findDbModelItem(pc, item);
dbModelItem = (DbModelItem) pc.refreshObject(dbModelItem);
Item newItem = dbModelItemToItem(dbModelItem);
try
{
item.copyFrom(newItem, Copyable.COPY_SHALLOW);
}
catch (CloneNotSupportedException e)
{
// Doesn't happen
}
// Repair hiearchy, establish links and instantiate the model
item.maintainReferences(ModelObject.RESOLVE_GLOBAL_REFS | ModelObject.RESOLVE_LOCAL_REFS | ModelObject.INSTANTIATE_ITEM);
}
catch (PersistenceException e)
{
pc.rollbackTransaction();
pc.release();
throw new ModelException("DatabaseOperation", "Error reloading descriptor of component '" + item.getQualifier() + "' to the database: "
+ e.getMessage(), e);
}
}