renamed dao methods to correctly reflect what they do

This commit is contained in:
root 2010-09-09 18:01:50 -07:00
parent dc4c4549d0
commit 76e5cf3321
43 changed files with 138 additions and 138 deletions

View File

@ -128,7 +128,7 @@ public class HighAvailabilityDaoImpl extends GenericDaoBase<WorkVO, Long> implem
final SearchCriteria<WorkVO> sc = CleanupSearch.create();
sc.setParameters("time", time);
sc.setParameters("step", HighAvailabilityManager.Step.Done, HighAvailabilityManager.Step.Cancelled);
delete(sc);
expunge(sc);
}
@Override
@ -161,7 +161,7 @@ public class HighAvailabilityDaoImpl extends GenericDaoBase<WorkVO, Long> implem
SearchCriteria<WorkVO> sc = PreviousWorkSearch.create();
sc.setParameters("instance", instanceId);
sc.setParameters("type", type);
return delete(sc) > 0;
return expunge(sc) > 0;
}
@Override

View File

@ -73,7 +73,7 @@ public class DetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implements De
txn.start();
SearchCriteria<DetailVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
delete(sc);
expunge(sc);
for (Map.Entry<String, String> detail : details.entrySet()) {
DetailVO vo = new DetailVO(hostId, detail.getKey(), detail.getValue());

View File

@ -206,7 +206,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("status", (Object[])statuses);
sc.setParameters("pod", podId);
List<Long> rs = searchAll(sc, null);
List<Long> rs = searchIncludingRemoved(sc, null);
if (rs.size() == 0) {
return 0;
}

View File

@ -60,7 +60,7 @@ public class StackMaidDaoImpl extends GenericDaoBase<StackMaidVO, Long> implemen
Filter filter = new Filter(StackMaidVO.class, "seq", false, 0L, (long)1);
List<StackMaidVO> l = listBy(sc, filter);
if(l != null && l.size() > 0) {
delete(l.get(0).getId());
expunge(l.get(0).getId());
return l.get(0);
}
@ -72,7 +72,7 @@ public class StackMaidDaoImpl extends GenericDaoBase<StackMaidVO, Long> implemen
SearchCriteria<StackMaidVO> sc = clearSearch.create();
sc.setParameters("msid", msid);
delete(sc);
expunge(sc);
}
@DB

View File

@ -34,7 +34,7 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO
SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();
sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
delete(sc);
expunge(sc);
}
@Override
@ -46,7 +46,7 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO
sc.addAnd("pending", SearchCriteria.Op.EQ, pending);
}
delete(sc);
expunge(sc);
}
@Override

View File

@ -46,6 +46,6 @@ public class NetworkRuleConfigDaoImpl extends GenericDaoBase<NetworkRuleConfigVO
public void deleteBySecurityGroup(long securityGroupId) {
SearchCriteria<NetworkRuleConfigVO> sc = SecurityGroupIdSearch.create();
sc.setParameters("securityGroupId", securityGroupId);
delete(sc);
expunge(sc);
}
}

View File

@ -79,7 +79,7 @@ public class IngressRuleDaoImpl extends GenericDaoBase<IngressRuleVO, Long> impl
public int deleteByNetworkGroup(long networkGroupId) {
SearchCriteria<IngressRuleVO> sc = networkGroupIdSearch.create();
sc.setParameters("networkGroupId", networkGroupId);
return delete(sc);
return expunge(sc);
}
@Override
@ -135,7 +135,7 @@ public class IngressRuleDaoImpl extends GenericDaoBase<IngressRuleVO, Long> impl
sc.setParameters("endPort", endPort);
sc.setParameters("allowedNetworkId", allowedGroupId);
return delete(sc);
return expunge(sc);
}
@ -148,7 +148,7 @@ public class IngressRuleDaoImpl extends GenericDaoBase<IngressRuleVO, Long> impl
sc.setParameters("endPort", endPort);
sc.setParameters("cidr", cidr);
return delete(sc);
return expunge(sc);
}
@Override

View File

@ -36,7 +36,7 @@ public class NetworkGroupRulesDaoImpl extends GenericDaoBase<NetworkGroupRulesVO
@Override
public List<NetworkGroupRulesVO> listNetworkGroupRules() {
Filter searchFilter = new Filter(NetworkGroupRulesVO.class, "id", true, null, null);
return listAllActive(searchFilter);
return listAll(searchFilter);
}
@Override

View File

@ -107,7 +107,7 @@ public class NetworkGroupVMMapDaoImpl extends GenericDaoBase<NetworkGroupVMMapVO
public int deleteVM(long instanceId) {
SearchCriteria<NetworkGroupVMMapVO> sc = ListByVmId.create();
sc.setParameters("instanceId", instanceId);
return super.delete(sc);
return super.expunge(sc);
}
@Override
@ -122,7 +122,7 @@ public class NetworkGroupVMMapDaoImpl extends GenericDaoBase<NetworkGroupVMMapVO
public List<Long> listVmIdsByNetworkGroup(long networkGroupId) {
SearchCriteria<Long> sc = ListVmIdByNetworkGroup.create();
sc.setParameters("networkGroupId", networkGroupId);
return searchAll(sc, null);
return searchIncludingRemoved(sc, null);
}
@Override

View File

@ -187,7 +187,7 @@ public class NetworkGroupWorkDaoImpl extends GenericDaoBase<NetworkGroupWorkVO,
sc.setParameters("taken", timeBefore);
sc.setParameters("step", Step.Done);
return delete(sc);
return expunge(sc);
}
@Override

View File

@ -49,7 +49,7 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase<ServiceOfferingVO, Lo
public ServiceOfferingVO findByName(String name) {
SearchCriteria<ServiceOfferingVO> sc = UniqueNameSearch.create();
sc.setParameters("name", name);
List<ServiceOfferingVO> vos = searchAll(sc, null, null, false);
List<ServiceOfferingVO> vos = searchIncludingRemoved(sc, null, null, false);
if (vos.size() == 0) {
return null;
}

View File

@ -69,15 +69,15 @@ public class DiskOfferingDaoImpl extends GenericDaoBase<DiskOfferingVO, Long> im
}
@Override
public List<DiskOfferingVO> searchAll(SearchCriteria<DiskOfferingVO> sc, final Filter filter, final Boolean lock, final boolean cache) {
public List<DiskOfferingVO> searchIncludingRemoved(SearchCriteria<DiskOfferingVO> sc, final Filter filter, final Boolean lock, final boolean cache) {
sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
return super.searchAll(sc, filter, lock, cache);
return super.searchIncludingRemoved(sc, filter, lock, cache);
}
@Override
public <K> List<K> searchAll(SearchCriteria<K> sc, final Filter filter) {
public <K> List<K> searchIncludingRemoved(SearchCriteria<K> sc, final Filter filter) {
sc.addAnd(_typeAttr, Op.EQ, Type.Disk);
return super.searchAll(sc, filter);
return super.searchIncludingRemoved(sc, filter);
}
@Override

View File

@ -92,7 +92,7 @@ public class LaunchPermissionDaoImpl extends GenericDaoBase<LaunchPermissionVO,
public void removeAllPermissions(long templateId) {
SearchCriteria<LaunchPermissionVO> sc = TemplateIdSearch.create();
sc.setParameters("templateId", templateId);
delete(sc);
expunge(sc);
}
@Override

View File

@ -76,7 +76,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
SearchCriteria<Long> sc = lastSnapSearch.create();
sc.setParameters("volumeId", volumeId);
sc.setParameters("snapId", snapId);
List<Long> prevSnapshots = searchAll(sc, null);
List<Long> prevSnapshots = searchIncludingRemoved(sc, null);
if(prevSnapshots != null && prevSnapshots.size() > 0 && prevSnapshots.get(0) != null) {
return prevSnapshots.get(0);
}

View File

@ -63,7 +63,7 @@ public class SnapshotPolicyRefDaoImpl extends GenericDaoBase<SnapshotPolicyRefVO
SearchCriteria<SnapshotPolicyRefVO> sc = snapPolicy.create();
sc.setParameters("snapshotId", snapshotId);
sc.setParameters("policyId", policyId);
return delete(sc);
return expunge(sc);
}
@Override

View File

@ -375,7 +375,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
sc.setParameters("status", (Object[])statuses);
sc.setParameters("pool", primaryStorageId);
List<Long> rs = searchAll(sc, null);
List<Long> rs = searchIncludingRemoved(sc, null);
if (rs.size() == 0) {
return 0;
}

View File

@ -48,7 +48,7 @@ public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailV
sc.setParameters("pool", poolId);
txn.start();
delete(sc);
expunge(sc);
for (Map.Entry<String, String> entry : details.entrySet()) {
StoragePoolDetailVO detail = new StoragePoolDetailVO(poolId, entry.getKey(), entry.getValue());
persist(detail);

View File

@ -71,7 +71,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
SearchCriteria<VolumeVO> sc = RemovedButNotDestroyedSearch.create();
sc.setParameters("destroyed", false);
return searchAll(sc, null, null, false);
return searchIncludingRemoved(sc, null, null, false);
}
@Override @DB
@ -224,7 +224,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
sc.setParameters("template", templateId);
sc.setParameters("pool", poolId);
List<Long> results = searchAll(sc, null);
List<Long> results = searchIncludingRemoved(sc, null);
assert results.size() > 0 : "How can this return a size of " + results.size();
return results.get(0) > 0;
@ -234,7 +234,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
public void deleteVolumesByInstance(long instanceId) {
SearchCriteria<VolumeVO> sc = InstanceIdSearch.create();
sc.setParameters("instanceId", instanceId);
delete(sc);
expunge(sc);
}
@Override
@ -359,7 +359,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
public Pair<Long, Long> getCountAndTotalByPool(long poolId) {
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
sc.setParameters("poolId", poolId);
List<SumCount> results = searchAll(sc, null);
List<SumCount> results = searchIncludingRemoved(sc, null);
SumCount sumCount = results.get(0);
return new Pair<Long, Long>(sumCount.count, sumCount.sum);
}

View File

@ -74,7 +74,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
SearchCriteria<AccountVO> sc = CleanupSearch.create();
sc.setParameters("cleanup", true);
return searchAll(sc, null, null, false);
return searchIncludingRemoved(sc, null, null, false);
}
public Pair<User, Account> findUserAccountByApiKey(String apiKey) {

View File

@ -1634,7 +1634,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory {
String cluster = startup.getCluster();
if (pod != null && dataCenter != null && pod.equalsIgnoreCase("default") && dataCenter.equalsIgnoreCase("default")) {
List<HostPodVO> pods = _podDao.listAll();
List<HostPodVO> pods = _podDao.listAllIncludingRemoved();
for (HostPodVO hpv : pods) {
if (checkCIDR(type, hpv, startup.getPrivateIpAddress(), startup.getPrivateNetmask())) {
pod = hpv.getName();

View File

@ -338,7 +338,7 @@ public class AlertManagerImpl implements AlertManager {
List<HostVO> hosts = _hostDao.search(sc, null);
// prep the service offerings
List<ServiceOfferingVO> offerings = _offeringsDao.listAll();
List<ServiceOfferingVO> offerings = _offeringsDao.listAllIncludingRemoved();
Map<Long, ServiceOfferingVO> offeringsMap = new HashMap<Long, ServiceOfferingVO>();
for (ServiceOfferingVO offering : offerings) {
offeringsMap.put(offering.getId(), offering);
@ -394,7 +394,7 @@ public class AlertManagerImpl implements AlertManager {
}
// Calculate storage pool capacity
List<StoragePoolVO> storagePools = _storagePoolDao.listAllActive();
List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
for (StoragePoolVO pool : storagePools) {
long disk = 0l;
Pair<Long, Long> sizes = _volumeDao.getCountAndTotalByPool(pool.getId());
@ -410,7 +410,7 @@ public class AlertManagerImpl implements AlertManager {
}
// Calculate new Public IP capacity
List<DataCenterVO> datacenters = _dcDao.listAll();
List<DataCenterVO> datacenters = _dcDao.listAllIncludingRemoved();
for (DataCenterVO datacenter : datacenters) {
long dcId = datacenter.getId();
@ -422,7 +422,7 @@ public class AlertManagerImpl implements AlertManager {
}
// Calculate new Private IP capacity
List<HostPodVO> pods = _podDao.listAll();
List<HostPodVO> pods = _podDao.listAllIncludingRemoved();
for (HostPodVO pod : pods) {
long podId = pod.getId();
long dcId = pod.getDataCenterId();
@ -465,7 +465,7 @@ public class AlertManagerImpl implements AlertManager {
}
try {
List<CapacityVO> capacityList = _capacityDao.listAll();
List<CapacityVO> capacityList = _capacityDao.listAllIncludingRemoved();
Map<String, List<CapacityVO>> capacityDcTypeMap = new HashMap<String, List<CapacityVO>>();
for (CapacityVO capacity : capacityList) {

View File

@ -476,7 +476,7 @@ public class AsyncJobManagerImpl implements AsyncJobManager {
List<AsyncJobVO> l = _jobDao.getExpiredJobs(cutTime, 100);
if(l != null && l.size() > 0) {
for(AsyncJobVO job : l) {
_jobDao.delete(job.getId());
_jobDao.expunge(job.getId());
}
}

View File

@ -186,7 +186,7 @@ public class SyncQueueManagerImpl implements SyncQueueManager {
if(itemVO != null) {
SyncQueueVO queueVO = _syncQueueDao.lock(itemVO.getQueueId(), true);
_syncQueueItemDao.delete(itemVO.getId());
_syncQueueItemDao.expunge(itemVO.getId());
queueVO.setLastProcessTime(null);
queueVO.setLastUpdated(DateUtil.currentGMTTime());

View File

@ -358,7 +358,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
HostPodVO pod = _podDao.findById(podId);
DataCenterVO zone = _zoneDao.findById(pod.getDataCenterId());
_podDao.delete(podId);
_podDao.expunge(podId);
// Delete private IP addresses in the pod
_privateIpAddressDao.deleteIpAddressByPod(podId);
@ -660,7 +660,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
DataCenterVO zone = _zoneDao.findById(zoneId);
_zoneDao.delete(zoneId);
_zoneDao.expunge(zoneId);
// Delete vNet
_zoneDao.deleteVnet(zoneId);
@ -1076,7 +1076,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
// Make sure there aren't any account VLANs in this zone
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAll();
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAllIncludingRemoved();
for (AccountVlanMapVO accountVlanMap : accountVlanMaps) {
VlanVO vlan = _vlanDao.findById(accountVlanMap.getVlanDbId());
if (vlan.getDataCenterId() == zone.getId()) {
@ -1171,12 +1171,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
if (accountId != null && vlanType.equals(VlanType.VirtualNetwork)){
if(!savePublicIPRangeForAccount(startIP, endIP, zoneId, vlan.getId(), accountId, _accountDao.findById(accountId).getDomainId())){
deletePublicIPRange(vlan.getId());
_vlanDao.delete(vlan.getId());
_vlanDao.expunge(vlan.getId());
throw new InternalErrorException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
}
}else if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId())) {
deletePublicIPRange(vlan.getId());
_vlanDao.delete(vlan.getId());
_vlanDao.expunge(vlan.getId());
throw new InternalErrorException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
}
@ -1240,7 +1240,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
// Delete the VLAN
boolean success = _vlanDao.delete(vlanDbId);
boolean success = _vlanDao.expunge(vlanDbId);
if (success) {
String[] ipRange = vlan.getIpRange().split("\\-");

View File

@ -48,7 +48,7 @@ AgentBasedConsoleProxyManager {
if(host != null) {
HostVO allocatedHost = null;
/*Is there a consoleproxy agent running on the same machine?*/
List<HostVO> hosts = _hostDao.listAll();
List<HostVO> hosts = _hostDao.listAllIncludingRemoved();
for (HostVO hv : hosts) {
if (hv.getType() == Host.Type.ConsoleProxy && hv.getPublicIpAddress().equalsIgnoreCase(host.getPublicIpAddress())) {
allocatedHost = hv;

View File

@ -52,7 +52,7 @@ public class StackMaidManagerImpl implements StackMaidManager {
private void cleanupLeftovers(List<StackMaidVO> l) {
for(StackMaidVO maid : l) {
StackMaid.doCleanup(maid);
_maidDao.delete(maid.getId());
_maidDao.expunge(maid.getId());
}
}

View File

@ -126,7 +126,7 @@ public class Db20to21MigrationUtil {
sb.done();
SearchCriteria<DcPod> sc = sb.create();
List<DcPod> results = _dcDao.searchAll(sc, (Filter)null);
List<DcPod> results = _dcDao.searchIncludingRemoved(sc, (Filter)null);
if(results.size() > 0) {
System.out.println("We've found following zones are deployed in your database");
for(DcPod cols : results) {
@ -153,7 +153,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<HostPodVO> sc = sb.create();
sc.setParameters("zoneId", zoneId);
List<HostPodVO> pods = _podDao.searchAll(sc, null, false, false);
List<HostPodVO> pods = _podDao.searchIncludingRemoved(sc, null, false, false);
if(pods.size() > 0) {
for(HostPodVO pod : pods) {
System.out.println("Migrating pod " + pod.getName() + " in zone " + zoneName + "...");
@ -202,7 +202,7 @@ public class Db20to21MigrationUtil {
sc.setParameters("type", Host.Type.Routing);
// join cluster for hosts in pod
List<HostVO> hostsInPod = _hostDao.searchAll(sc, null, false, false);
List<HostVO> hostsInPod = _hostDao.searchIncludingRemoved(sc, null, false, false);
if(hostsInPod.size() > 0) {
if(cluster == null) {
cluster = new ClusterVO(zoneId, podId, String.valueOf(podId));
@ -228,7 +228,7 @@ public class Db20to21MigrationUtil {
scPool.setParameters("pod", podId);
scPool.setParameters("poolType", StoragePoolType.NetworkFilesystem.toString(), StoragePoolType.IscsiLUN.toString());
List<StoragePoolVO> sPoolsInPod = _spDao.searchAll(scPool, null, false, false);
List<StoragePoolVO> sPoolsInPod = _spDao.searchIncludingRemoved(scPool, null, false, false);
if(sPoolsInPod.size() > 0) {
if(cluster == null) {
cluster = new ClusterVO(zoneId, podId, String.valueOf(podId));
@ -265,7 +265,7 @@ public class Db20to21MigrationUtil {
System.out.println("Migrating domains...");
// we shouldn't have too many domains in the system, use a very dumb way to setup domain path
List<DomainVO> domains = _domainDao.listAll();
List<DomainVO> domains = _domainDao.listAllIncludingRemoved();
for(DomainVO domain : domains) {
StringBuilder path = new StringBuilder();
composeDomainPath(domain, path);
@ -284,7 +284,7 @@ public class Db20to21MigrationUtil {
long seq = getServiceOfferingStartSequence();
List<ServiceOffering20VO> oldServiceOfferings = _serviceOffering20Dao.listAll();
List<ServiceOffering20VO> oldServiceOfferings = _serviceOffering20Dao.listAllIncludingRemoved();
for(ServiceOffering20VO so20 : oldServiceOfferings) {
ServiceOffering21VO so21 = new ServiceOffering21VO(so20.getName(), so20.getCpu(), so20.getRamSize(), so20.getSpeed(), so20.getRateMbps(),
so20.getMulticastRateMbps(), so20.getOfferHA(), so20.getDisplayText(), so20.getGuestIpType(),
@ -435,7 +435,7 @@ public class Db20to21MigrationUtil {
private void migrateDiskOfferings() {
System.out.println("Migrating disk offering...");
List<DiskOffering20VO> oldDiskOfferings = _diskOffering20Dao.listAll();
List<DiskOffering20VO> oldDiskOfferings = _diskOffering20Dao.listAllIncludingRemoved();
long maxDiskOfferingId = _domRServiceOfferingId;
maxDiskOfferingId += 100;
@ -460,7 +460,7 @@ public class Db20to21MigrationUtil {
System.out.println("Fixup NULL disk_offering_id references in volumes table ...");
SearchCriteria<DiskOffering21VO> scDiskOffering = _diskOffering21Dao.createSearchCriteria();
List<DiskOffering21VO> offeringList = _diskOffering21Dao.searchAll(scDiskOffering,
List<DiskOffering21VO> offeringList = _diskOffering21Dao.searchIncludingRemoved(scDiskOffering,
new Filter(DiskOffering21VO.class, "diskSize", true, null, null), false, false);
for(DiskOffering21VO offering : offeringList) {
@ -472,7 +472,7 @@ public class Db20to21MigrationUtil {
sb.done();
SearchCriteria<VolumeVO> sc = sb.create();
List<VolumeVO> volumes = _volumeDao.searchAll(sc, null, false, false);
List<VolumeVO> volumes = _volumeDao.searchIncludingRemoved(sc, null, false, false);
if(volumes.size() > 0) {
for(VolumeVO vol : volumes) {
@ -558,7 +558,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<ConsoleProxyVO> sc = sb.create();
sc.setParameters("zoneId", zoneId);
List<ConsoleProxyVO> proxies =_consoleProxyDao.searchAll(sc, null, false, false);
List<ConsoleProxyVO> proxies =_consoleProxyDao.searchIncludingRemoved(sc, null, false, false);
for(ConsoleProxyVO proxy : proxies) {
String[] macAddresses = _dcDao.getNextAvailableMacAddressPair(zoneId, (1L << 31));
String guestMacAddress = macAddresses[0];
@ -585,7 +585,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<SecondaryStorageVmVO> sc2 = sb2.create();
sc2.setParameters("zoneId", zoneId);
List<SecondaryStorageVmVO> secStorageVms =_secStorageVmDao.searchAll(sc2, null, false, false);
List<SecondaryStorageVmVO> secStorageVms =_secStorageVmDao.searchIncludingRemoved(sc2, null, false, false);
for(SecondaryStorageVmVO secStorageVm : secStorageVms) {
String[] macAddresses = _dcDao.getNextAvailableMacAddressPair(zoneId, (1L << 31));
String guestMacAddress = macAddresses[0];
@ -612,7 +612,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<DomainRouterVO> sc3 = sb3.create();
sc3.setParameters("zoneId", zoneId);
List<DomainRouterVO> domRs = _routerDao.searchAll(sc3, null, false, false);
List<DomainRouterVO> domRs = _routerDao.searchIncludingRemoved(sc3, null, false, false);
for(DomainRouterVO router : domRs) {
if(router.getState() == State.Running || router.getState() == State.Starting) {
router.setState(State.Stopping);
@ -633,7 +633,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<VMInstanceVO> sc = sb.create();
sc.setParameters("zoneId", zoneId);
sc.setParameters("podId", podId);
List<VMInstanceVO> vmInstances = _vmInstanceDao.searchAll(sc, null, false, false);
List<VMInstanceVO> vmInstances = _vmInstanceDao.searchIncludingRemoved(sc, null, false, false);
List<HostVO> podHosts = getHostsInPod(zoneId, podId);
for(VMInstanceVO vm : vmInstances) {
if(vm.getHostId() != null) {
@ -660,13 +660,13 @@ public class Db20to21MigrationUtil {
sc.setParameters("podId", podId);
sc.setParameters("type", Host.Type.Routing.toString());
return _hostDao.searchAll(sc, null, false, false);
return _hostDao.searchIncludingRemoved(sc, null, false, false);
}
private void migrateVolumDeviceIds() {
System.out.println("Migrating device_id for volumes, this may take a while, please wait...");
SearchCriteria<VMInstanceVO> sc = _vmInstanceDao.createSearchCriteria();
List<VMInstanceVO> vmInstances = _vmInstanceDao.searchAll(sc, null, false, false);
List<VMInstanceVO> vmInstances = _vmInstanceDao.searchIncludingRemoved(sc, null, false, false);
long deviceId = 1;
for(VMInstanceVO vm: vmInstances) {
@ -677,7 +677,7 @@ public class Db20to21MigrationUtil {
SearchCriteria<VolumeVO> sc2 = sb.create();
sc2.setParameters("instanceId", vm.getId());
List<VolumeVO> volumes = _volumeDao.searchAll(sc2, null, false, false);
List<VolumeVO> volumes = _volumeDao.searchIncludingRemoved(sc2, null, false, false);
deviceId = 1; // reset for each VM iteration
for(VolumeVO vol : volumes) {
if(vol.getVolumeType() == VolumeType.ROOT) {
@ -707,7 +707,7 @@ public class Db20to21MigrationUtil {
System.out.println("Migrating pool type for volumes...");
SearchCriteria<VolumeVO> sc = _volumeDao.createSearchCriteria();
List<VolumeVO> volumes = _volumeDao.searchAll(sc, null, false, false);
List<VolumeVO> volumes = _volumeDao.searchIncludingRemoved(sc, null, false, false);
for(VolumeVO vol : volumes) {
if(vol.getPoolId() != null) {
StoragePoolVO pool = _poolDao.findById(vol.getPoolId());

View File

@ -459,7 +459,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
List<VolumeVO> vols = _storageMgr.create(account, router, rtrTemplate, dc, pod, _offering, null,0);
if (vols == null){
_ipAddressDao.unassignIpAddress(guestIp);
_routerDao.delete(router.getId());
_routerDao.expunge(router.getId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to create dhcp server in storage host or pool in pod " + pod.getName() + " (id:" + pod.getId() + ")");
}
@ -493,7 +493,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
txn.rollback();
if (router.getState() == State.Creating) {
_routerDao.delete(router.getId());
_routerDao.expunge(router.getId());
}
return null;
} finally {
@ -635,7 +635,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
break;
}
_routerDao.delete(router.getId());
_routerDao.expunge(router.getId());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find storage host or pool in pod " + pod.first().getName() + " (id:" + pod.first().getId() + "), checking other pods");
}
@ -670,7 +670,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
txn.rollback();
if (router != null && router.getState() == State.Creating) {
_routerDao.delete(router.getId());
_routerDao.expunge(router.getId());
}
return null;
} finally {

View File

@ -774,7 +774,7 @@ public class NetworkGroupManagerImpl implements NetworkGroupManager {
txn.rollback();
throw new ResourceInUseException("Cannot delete group when there are ingress rules in this group");
}
_networkGroupDao.delete(groupId);
_networkGroupDao.expunge(groupId);
txn.commit();
}

View File

@ -970,7 +970,7 @@ public class ManagementServerImpl implements ManagementServer {
// All vm instances have been destroyed, delete the security group -> instance_id mappings
SearchCriteria<SecurityGroupVMMapVO> sc = _securityGroupVMMapDao.createSearchCriteria();
sc.addAnd("securityGroupId", SearchCriteria.Op.EQ, securityGroup.getId());
_securityGroupVMMapDao.delete(sc);
_securityGroupVMMapDao.expunge(sc);
// now clean the network rules and security groups themselves
_networkRuleConfigDao.deleteBySecurityGroup(securityGroup.getId());
@ -2847,12 +2847,12 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public List<DataCenterVO> listDataCenters() {
return _dcDao.listAllActive();
return _dcDao.listAll();
}
@Override
public List<DataCenterVO> listDataCentersBy(long accountId) {
List<DataCenterVO> dcs = _dcDao.listAllActive();
List<DataCenterVO> dcs = _dcDao.listAll();
List<DomainRouterVO> routers = _routerDao.listBy(accountId);
for (Iterator<DataCenterVO> iter = dcs.iterator(); iter.hasNext();) {
DataCenterVO dc = iter.next();
@ -3647,7 +3647,7 @@ public class ManagementServerImpl implements ManagementServer {
} else if (fwdings.size() == 1) {
fwRule = fwdings.get(0);
if (fwRule.getPrivateIpAddress().equalsIgnoreCase(privateIp) && fwRule.getPrivatePort().equals(privatePort)) {
_firewallRulesDao.delete(fwRule.getId());
_firewallRulesDao.expunge(fwRule.getId());
} else {
throw new InvalidParameterValueException("No such rule");
}
@ -3746,7 +3746,7 @@ public class ManagementServerImpl implements ManagementServer {
if (!success) {
throw new InternalErrorException("Failed to update router");
}
_firewallRulesDao.delete(fwRule.getId());
_firewallRulesDao.expunge(fwRule.getId());
txn.commit();
return success;
@ -4483,7 +4483,7 @@ public class ManagementServerImpl implements ManagementServer {
if (limitId == null)
return false;
return _resourceLimitDao.delete(limitId);
return _resourceLimitDao.expunge(limitId);
}
@Override
@ -4516,7 +4516,7 @@ public class ManagementServerImpl implements ManagementServer {
{
//account belongs to admin
//return all limits
limits = _resourceLimitDao.listAll();
limits = _resourceLimitDao.listAllIncludingRemoved();
return limits;
}
}
@ -4525,7 +4525,7 @@ public class ManagementServerImpl implements ManagementServer {
//return all the records for resource limits (bug:3778)
if(accountId==1 && domainId==1)
{
limits = _resourceLimitDao.listAll();
limits = _resourceLimitDao.listAllIncludingRemoved();
return limits;
}
}
@ -4685,12 +4685,12 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public List<ServiceOfferingVO> listAllServiceOfferings() {
return _offeringsDao.listAll();
return _offeringsDao.listAllIncludingRemoved();
}
@Override
public List<HostVO> listAllActiveHosts() {
return _hostDao.listAllActive();
return _hostDao.listAll();
}
@Override
@ -5474,7 +5474,7 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public List<DomainRouterVO> listAllActiveRouters() {
return _routerDao.listAllActive();
return _routerDao.listAll();
}
@Override
@ -5861,7 +5861,7 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public List<DiskTemplateVO> listAllActiveDiskTemplates() {
return _diskTemplateDao.listAllActive();
return _diskTemplateDao.listAll();
}
@Override
@ -6114,7 +6114,7 @@ public class ManagementServerImpl implements ManagementServer {
@Override
public List<VMTemplateVO> listAllTemplates() {
return _templateDao.listAll();
return _templateDao.listAllIncludingRemoved();
}
@Override
@ -7924,7 +7924,7 @@ public class ManagementServerImpl implements ManagementServer {
List<EventVO> oldEvents = _eventDao.listOlderEvents(purgeTime);
s_logger.debug("Found "+oldEvents.size()+" events to be purged");
for (EventVO event : oldEvents){
_eventDao.delete(event.getId());
_eventDao.expunge(event.getId());
}
} catch (Exception e) {
s_logger.error("Exception ", e);

View File

@ -284,7 +284,7 @@ public class StatsCollector {
ConcurrentHashMap<Long, StorageStats> storagePoolStats = new ConcurrentHashMap<Long, StorageStats>();
List<StoragePoolVO> storagePools = _storagePoolDao.listAllActive();
List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
for (StoragePoolVO pool: storagePools) {
GetStorageStatsCommand command = new GetStorageStatsCommand(pool.getUuid(), pool.getPoolType(), pool.getPath());
Answer answer = _storageManager.sendToPool(pool, command);
@ -377,7 +377,7 @@ public class StatsCollector {
class VolumeCollector implements Runnable {
public void run() {
try {
List<VolumeVO> volumes = _volsDao.listAllActive();
List<VolumeVO> volumes = _volsDao.listAll();
Map<Long, List<VolumeCommand>> commandsByPool = new HashMap<Long, List<VolumeCommand>>();
for (VolumeVO volume : volumes) {

View File

@ -1417,7 +1417,7 @@ public class StorageManagerImpl implements StorageManager {
}
if (poolHosts.isEmpty()) {
_storagePoolDao.delete(pool.getId());
_storagePoolDao.expunge(pool.getId());
pool = null;
} else {
createCapacityEntry(pool);
@ -1885,7 +1885,7 @@ public class StorageManagerImpl implements StorageManager {
public void cleanupStorage(boolean recurring) {
// Cleanup primary storage pools
List<StoragePoolVO> storagePools = _storagePoolDao.listAllActive();
List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
for (StoragePoolVO pool : storagePools) {
try {
if (recurring && pool.isLocal()) {

View File

@ -120,7 +120,7 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
SearchCriteria<Long> sc = VmsOnPoolSearch.create();
sc.setJoinParameters("volumeJoin", "poolId", pool.getId());
sc.setParameters("state", State.Expunging);
List<Long> vmsOnHost = _vmInstanceDao.searchAll(sc, null);
List<Long> vmsOnHost = _vmInstanceDao.searchIncludingRemoved(sc, null);
if(s_logger.isDebugEnabled()) {
s_logger.debug("Found " + vmsOnHost.size() + " VM instances are alloacated at host " + spHost.getHostId() + " with local storage pool " + pool.getName());

View File

@ -307,7 +307,7 @@ public class DownloadMonitorImpl implements DownloadMonitor {
List<DataCenterVO> dcs = new ArrayList<DataCenterVO>();
if (zoneId == null) {
dcs.addAll(_dcDao.listAll());
dcs.addAll(_dcDao.listAllIncludingRemoved());
} else {
dcs.add(_dcDao.findById(zoneId));
}

View File

@ -100,7 +100,7 @@ public class PreallocatedLunDaoImpl extends GenericDaoBase<PreallocatedLunVO, Lo
SearchCriteria<PreallocatedLunVO> sc = DeleteSearch.create();
sc.setParameters("id", id);
return delete(sc) > 0;
return expunge(sc) > 0;
}
@Override
@ -184,7 +184,7 @@ public class PreallocatedLunDaoImpl extends GenericDaoBase<PreallocatedLunVO, Lo
SearchCriteria<Long> sc = TotalSizeSearch.create();
sc.setParameters("target", targetIqn);
List<Long> results = searchAll(sc, null);
List<Long> results = searchIncludingRemoved(sc, null);
if (results.size() == 0) {
return 0;
}
@ -197,7 +197,7 @@ public class PreallocatedLunDaoImpl extends GenericDaoBase<PreallocatedLunVO, Lo
SearchCriteria<Long> sc = UsedSizeSearch.create();
sc.setParameters("target", targetIqn);
List<Long> results = searchAll(sc, null);
List<Long> results = searchIncludingRemoved(sc, null);
if (results.size() == 0) {
return 0;
}
@ -209,7 +209,7 @@ public class PreallocatedLunDaoImpl extends GenericDaoBase<PreallocatedLunVO, Lo
public List<String> findDistinctTagsForTarget(String targetIqn) {
SearchCriteria<String> sc = DetailsSearch.create();
sc.setJoinParameters("target", "targetiqn", targetIqn);
return _detailsDao.searchAll(sc, null);
return _detailsDao.searchIncludingRemoved(sc, null);
}
@Override @DB

View File

@ -271,7 +271,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov
_vmTemplateZoneDao.persist(vmTemplateZone);
}
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAllActive();
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
for (VMTemplateVO vt: allTemplates){
if (vt.isCrossZones()){
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());

View File

@ -527,7 +527,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
return true;
}
boolean success = true;
List<DataCenterVO> allZones = _dcDao.listAllActive();
List<DataCenterVO> allZones = _dcDao.listAll();
for (DataCenterVO zone: allZones){
success = success && generateFirewallConfigurationForZone( zone.getId());
}
@ -953,7 +953,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
try {
checkPendingSecStorageVMs();
List<DataCenterVO> datacenters = _dcDao.listAll();
List<DataCenterVO> datacenters = _dcDao.listAllIncludingRemoved();
for (DataCenterVO dc: datacenters){

View File

@ -368,7 +368,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
// The snapshot was not successfully created
createdSnapshot = _snapshotDao.findById(id);
// delete from the snapshots table
_snapshotDao.delete(id);
_snapshotDao.expunge(id);
}
@ -431,7 +431,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
if (answer.getResult()) {
// The expected snapshot details on the primary is the same as it would be if this snapshot was never taken at all
// Just delete the entry in the table
_snapshotDao.delete(id);
_snapshotDao.expunge(id);
// Create an event saying the snapshot failed. ??
// An event is not generated when validatePreviousSnapshotBackup fails. So not generating it here too.
}
@ -566,7 +566,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
long pprevSnapshotId = prevSnapshot.getPrevSnapshotId();
snapshot.setPrevSnapshotId(pprevSnapshotId);
_snapshotDao.update(snapshot.getId(), snapshot);
_snapshotDao.delete(prevSnapshot.getId());
_snapshotDao.expunge(prevSnapshot.getId());
EventVO event = new EventVO();
String eventParams = "id=" + prevSnapshot.getId() + "\nssName=" + prevSnapshot.getName();
@ -695,7 +695,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
SnapshotScheduleVO snapshotSchedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, true);
if (snapshotSchedule != null) {
// We should lock the row before deleting it as it is also being deleted by the scheduler.
_snapshotScheduleDao.delete(snapshotSchedule.getId());
_snapshotScheduleDao.expunge(snapshotSchedule.getId());
}
}
}
@ -947,7 +947,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
if(isLastSnap){
_snapshotDao.remove(snapshotId);
} else {
_snapshotDao.delete(snapshotId);
_snapshotDao.expunge(snapshotId);
// In the snapshots table,
// the last_snapshot_id field of the next snapshot becomes the last_snapshot_id of the deleted snapshot
long prevSnapshotId = snapshot.getPrevSnapshotId();
@ -1053,7 +1053,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
// Either way delete the snapshots for this volume.
List<SnapshotVO> snapshots = listSnapsforVolume(volumeId);
for (SnapshotVO snapshot: snapshots) {
if(_snapshotDao.delete(snapshot.getId())){
if(_snapshotDao.expunge(snapshot.getId())){
_accountMgr.decrementResourceCount(accountId, ResourceType.snapshot);
//Log event after successful deletion
@ -1197,7 +1197,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
// We can only delete the schedules in the future, not the ones which are already executing.
SnapshotScheduleVO snapshotSchedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, Snapshot.MANUAL_POLICY_ID, false);
if (snapshotSchedule != null) {
_snapshotScheduleDao.delete(snapshotSchedule.getId());
_snapshotScheduleDao.expunge(snapshotSchedule.getId());
}
}
@ -1256,7 +1256,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
}
if(success){
_snapshotDao.delete(snapshot.getId());
_snapshotDao.expunge(snapshot.getId());
}
return success;
}

View File

@ -313,7 +313,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
if (_snapshotScheduleDao.findById(expectedId) != null) {
// We need to acquire a lock and delete it, then release the lock.
// But I don't know how to.
_snapshotScheduleDao.delete(expectedId);
_snapshotScheduleDao.expunge(expectedId);
}
if (policyId.longValue() == Snapshot.MANUAL_POLICY_ID) {
// Don't need to schedule the next job for this.
@ -338,7 +338,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
SnapshotScheduleVO schedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false);
boolean success = true;
if (schedule != null) {
success = _snapshotScheduleDao.delete(schedule.getId());
success = _snapshotScheduleDao.expunge(schedule.getId());
}
if(!success){
s_logger.debug("Error while deleting Snapshot schedule with Id: "+schedule.getId());

View File

@ -127,7 +127,7 @@ public class TemplateManagerImpl implements TemplateManager {
VMTemplateVO template = new VMTemplateVO(id, name, format, isPublic, featured, fs, url.toString(), requiresHvm, bits, accountId, chksum, displayText, enablePassword, guestOSId, bootable);
if (zoneId == null) {
List<DataCenterVO> dcs = _dcDao.listAll();
List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
for (DataCenterVO dc: dcs) {
_tmpltDao.addTemplateToZone(template, dc.getId());

View File

@ -1547,7 +1547,7 @@ public class UserVmManagerImpl implements UserVmManager {
} catch (Throwable th) {
s_logger.error("Unable to create vm", th);
if (vm != null) {
_vmDao.delete(vmId);
_vmDao.expunge(vmId);
}
_accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
_accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
@ -2231,7 +2231,7 @@ public class UserVmManagerImpl implements UserVmManager {
if ((answer != null) && answer.getResult()) {
// delete the snapshot from the database
_snapshotDao.delete(snapshotId);
_snapshotDao.expunge(snapshotId);
success = true;
}
if (answer != null) {
@ -2287,7 +2287,7 @@ public class UserVmManagerImpl implements UserVmManager {
Transaction txn = Transaction.currentTxn();
txn.start();
createdSnapshot = _snapshotDao.findById(id);
_snapshotDao.delete(id);
_snapshotDao.expunge(id);
txn.commit();
createdSnapshot = null;
@ -2709,7 +2709,7 @@ public class UserVmManagerImpl implements UserVmManager {
boolean addedToGroups = _networkGroupManager.addInstanceToGroups(vmId, networkGroups);
if (!addedToGroups) {
s_logger.warn("Not all specified network groups can be found");
_vmDao.delete(vm.getId());
_vmDao.expunge(vm.getId());
throw new InvalidParameterValueException("Not all specified network groups can be found");
}
@ -2717,7 +2717,7 @@ public class UserVmManagerImpl implements UserVmManager {
try {
poolId = _storageMgr.createUserVM(account, vm, template, dc, pod.first(), offering, diskOffering, a,size);
} catch (CloudRuntimeException e) {
_vmDao.delete(vmId);
_vmDao.expunge(vmId);
_ipAddressDao.unassignIpAddress(guestIp);
s_logger.debug("Released a guest ip address because we could not find storage: ip=" + guestIp);
guestIp = null;
@ -2878,7 +2878,7 @@ public class UserVmManagerImpl implements UserVmManager {
try {
poolId = _storageMgr.createUserVM(account, vm, template, dc, pod.first(), offering, diskOffering,a,size);
} catch (CloudRuntimeException e) {
_vmDao.delete(vmId);
_vmDao.expunge(vmId);
_accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
_accountMgr.decrementResourceCount(account.getId(), ResourceType.volume, numVolumes);
if (s_logger.isDebugEnabled()) {

View File

@ -125,14 +125,14 @@ public interface GenericDao<T, ID extends Serializable> {
* Look for all active rows.
* @return list of entity beans.
*/
List<T> listAllActive();
List<T> listAll();
/**
* Look for all active rows.
* @param filter filter to limit the results
* @return list of entity beans.
*/
List<T> listAllActive(Filter filter);
List<T> listAll(Filter filter);
/**
@ -143,7 +143,7 @@ public interface GenericDao<T, ID extends Serializable> {
*/
List<T> search(SearchCriteria<T> sc, Filter filter);
List<T> searchAll(SearchCriteria<T> sc, final Filter filter, final Boolean lock, final boolean cache);
List<T> searchIncludingRemoved(SearchCriteria<T> sc, final Filter filter, final Boolean lock, final boolean cache);
/**
* Customized search with SearchCritiria
@ -151,20 +151,20 @@ public interface GenericDao<T, ID extends Serializable> {
* @param filter
* @return list of entity beans.
*/
public <M> List<M> searchAll(SearchCriteria<M> sc, Filter filter);
public <M> List<M> searchIncludingRemoved(SearchCriteria<M> sc, Filter filter);
/**
* Retrieves the entire table.
* @return collection of entity beans.
**/
List<T> listAll();
List<T> listAllIncludingRemoved();
/**
* Retrieves the entire table.
* @param filter filter to limit the returns.
* @return collection of entity beans.
**/
List<T> listAll(Filter filter);
List<T> listAllIncludingRemoved(Filter filter);
/**
* Persist the entity bean. The id field of the entity is updated with
@ -188,14 +188,14 @@ public interface GenericDao<T, ID extends Serializable> {
* @param id
* @return true if removed.
*/
boolean delete(ID id);
boolean expunge(ID id);
/**
* remove the entity bean specified by the search criteria
* @param sc
* @return number of rows deleted
*/
int delete(final SearchCriteria<T> sc);
int expunge(final SearchCriteria<T> sc);
/**
* expunge the removed rows.

View File

@ -293,11 +293,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
sc.addAnd(_removed.second().field.getName(), SearchCriteria.Op.NULL);
}
return searchAll(sc, filter, lock, cache);
return searchIncludingRemoved(sc, filter, lock, cache);
}
@Override
public List<T> searchAll(SearchCriteria<T> sc, final Filter filter, final Boolean lock, final boolean cache) {
public List<T> searchIncludingRemoved(SearchCriteria<T> sc, final Filter filter, final Boolean lock, final boolean cache) {
String clause = sc != null ? sc.getWhereClause() : null;
if (clause != null && clause.length() == 0) {
clause = null;
@ -363,7 +363,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
@Override @SuppressWarnings("unchecked") @DB
public <M> List<M> searchAll(SearchCriteria<M> sc, final Filter filter) {
public <M> List<M> searchIncludingRemoved(SearchCriteria<M> sc, final Filter filter) {
String clause = sc != null ? sc.getWhereClause() : null;
if (clause != null && clause.length() == 0) {
clause = null;
@ -723,7 +723,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
protected T findOneBy(final SearchCriteria<T> sc) {
Filter filter = new Filter(1);
List<T> results = searchAll(sc, filter, null, false);
List<T> results = searchIncludingRemoved(sc, filter, null, false);
assert results.size() <= 1 : "Didn't the limiting worked?";
return results.size() == 0 ? null : results.get(0);
}
@ -751,7 +751,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
@DB(txn=false)
protected List<T> listBy(final SearchCriteria<T> sc, final Filter filter) {
return searchAll(sc, filter, null, false);
return searchIncludingRemoved(sc, filter, null, false);
}
@DB(txn=false)
@ -837,8 +837,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
@Override @DB(txn=false)
public List<T> listAll() {
return listAll(null);
public List<T> listAllIncludingRemoved() {
return listAllIncludingRemoved(null);
}
@DB(txn=false)
@ -872,7 +872,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
@Override @DB(txn=false)
public List<T> listAll(final Filter filter) {
public List<T> listAllIncludingRemoved(final Filter filter) {
final StringBuilder sql = createPartialSelectSql(null, false);
addFilter(sql, filter);
@ -903,14 +903,14 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
@Override @DB(txn=false)
public List<T> listAllActive() {
return listAllActive(null);
public List<T> listAll() {
return listAll(null);
}
@Override @DB(txn=false)
public List<T> listAllActive(final Filter filter) {
public List<T> listAll(final Filter filter) {
if (_removed == null) {
return listAll(filter);
return listAllIncludingRemoved(filter);
}
final StringBuilder sql = createPartialSelectSql(null, true);
@ -921,7 +921,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
@Override
public boolean delete(final ID id) {
public boolean expunge(final ID id) {
final Transaction txn = Transaction.currentTxn();
PreparedStatement pstmt = s_initStmt;
String sql = null;
@ -952,7 +952,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
// FIXME: Does not work for joins.
@Override
public int delete(final SearchCriteria<T> sc) {
public int expunge(final SearchCriteria<T> sc) {
final StringBuilder str = new StringBuilder("DELETE FROM ");
str.append(_table);
str.append(" WHERE ");
@ -1269,7 +1269,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
@Override
public boolean remove(final ID id) {
if (_removeSql == null) {
return delete(id);
return expunge(id);
}
final Transaction txn = Transaction.currentTxn();
@ -1299,7 +1299,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
@Override
public int remove(SearchCriteria<T> sc) {
if (_removeSql == null) {
return delete(sc);
return expunge(sc);
}
T vo = createForUpdate();
@ -1337,7 +1337,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
createCache(params);
final boolean load = Boolean.parseBoolean((String)params.get("cache.preload"));
if (load) {
listAllActive();
listAll();
}
return true;