Source:
<code>private boolean UpdateStorageDomainsInDb() { boolean result = TransactionSupport.executeInNewTransaction(new TransactionMethod<Boolean>() { @Override public Boolean runInTransaction() { for (Guid storageDomainId : getParameters().getStorages()) { storage_domains storageDomain = DbFacade.getInstance().getStorageDomainDAO().get( storageDomainId); if (storageDomain != null) { storage_pool_iso_map mapFromDB = DbFacade.getInstance() .getStoragePoolIsoMapDAO() .get(new StoragePoolIsoMapId(storageDomain.getId(), getStoragePool().getId())); boolean existingInDb = mapFromDB != null; if (existingInDb) { getCompensationContext().snapshotEntity(mapFromDB); } final storage_domain_static staticDomain = storageDomain.getStorageStaticData(); getCompensationContext().snapshotEntity(staticDomain); if (getStoragePool().getcompatibility_version().compareTo(Version.v3_1) >= 0 && staticDomain.getStorageFormat() != StorageFormatType.V3) { staticDomain.setStorageFormat(StorageFormatType.V3); <START> getStorageDomainStaticDAO().update(staticDomain); <END> } storageDomain.setstorage_pool_id(getStoragePool().getId()); if (masterStorageDomain == null && storageDomain.getstorage_domain_type() == StorageDomainType.Data) { getStoragePool().setmaster_domain_version(getStoragePool().getmaster_domain_version() + 1); storageDomain.setstorage_domain_type(StorageDomainType.Master); getStorageDomainStaticDAO().update(staticDomain); masterStorageDomain = storageDomain; updateStoragePoolInDiffTransaction(); } storageDomain.setstatus(StorageDomainStatus.Locked); if (existingInDb) { DbFacade.getInstance() .getStoragePoolIsoMapDAO() .update(storageDomain.getStoragePoolIsoMapData()); } else { DbFacade.getInstance() .getStoragePoolIsoMapDAO() .save(storageDomain.getStoragePoolIsoMapData()); getCompensationContext().snapshotNewEntity(storageDomain.getStoragePoolIsoMapData()); } } else { return false; } } getCompensationContext().stateChanged(); return true; } }); return result && masterStorageDomain != null; }</code><technical_language>updates is useless, flow runs in transaction, changes transaction is committed, is a reason perform unneeded operation? code inefficient unreadable</technical_language>

Target:
private boolean UpdateStorageDomainsInDb() { boolean result = TransactionSupport.executeInNewTransaction(new TransactionMethod<Boolean>() { @Override public Boolean runInTransaction() { for (Guid storageDomainId : getParameters().getStorages()) { storage_domains storageDomain = DbFacade.getInstance().getStorageDomainDAO().get( storageDomainId); if (storageDomain != null) { storage_pool_iso_map mapFromDB = DbFacade.getInstance() .getStoragePoolIsoMapDAO() .get(new StoragePoolIsoMapId(storageDomain.getId(), getStoragePool().getId())); boolean existingInDb = mapFromDB != null; if (existingInDb) { getCompensationContext().snapshotEntity(mapFromDB); } final storage_domain_static staticDomain = storageDomain.getStorageStaticData(); boolean staticDomainChanged = false; if (getStoragePool().getcompatibility_version().compareTo(Version.v3_1) >= 0 && staticDomain.getStorageFormat() != StorageFormatType.V3) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } staticDomain.setStorageFormat(StorageFormatType.V3); staticDomainChanged = true; } storageDomain.setstorage_pool_id(getStoragePool().getId()); if (masterStorageDomain == null && storageDomain.getstorage_domain_type() == StorageDomainType.Data) { if (!staticDomainChanged) { getCompensationContext().snapshotEntity(staticDomain); } getStoragePool().setmaster_domain_version(getStoragePool().getmaster_domain_version() + 1); storageDomain.setstorage_domain_type(StorageDomainType.Master); staticDomainChanged = true; masterStorageDomain = storageDomain; updateStoragePoolInDiffTransaction(); } if (staticDomainChanged) { getStorageDomainStaticDAO().update(staticDomain); } storageDomain.setstatus(StorageDomainStatus.Locked); if (existingInDb) { DbFacade.getInstance() .getStoragePoolIsoMapDAO() .update(storageDomain.getStoragePoolIsoMapData()); } else { DbFacade.getInstance() .getStoragePoolIsoMapDAO() .save(storageDomain.getStoragePoolIsoMapData()); getCompensationContext().snapshotNewEntity(storageDomain.getStoragePoolIsoMapData()); } } else { return false; } } getCompensationContext().stateChanged(); return true; } }); return result && masterStorageDomain != null; }