cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [01/10] git commit: updated refs/heads/master to b60eef3
Date Sat, 28 Sep 2013 14:50:22 GMT
Updated Branches:
  refs/heads/master 58f287c62 -> b60eef3e8


Continue to merge SearchCriteria2 and GenericSearchBuilder


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a964cf54
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a964cf54
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a964cf54

Branch: refs/heads/master
Commit: a964cf549e3f7682e6db05e3ffeb6700b26df732
Parents: af8832f
Author: Alex Huang <alex.huang@citrix.com>
Authored: Fri Sep 27 15:19:27 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Sat Sep 28 07:53:24 2013 -0700

----------------------------------------------------------------------
 .../entity/api/db/dao/EngineClusterDaoImpl.java |   6 +-
 .../entity/api/db/dao/EngineHostDaoImpl.java    |   2 +-
 .../entity/api/db/dao/EngineHostPodDaoImpl.java |   2 +-
 .../src/com/cloud/dc/dao/ClusterDaoImpl.java    |   8 +-
 .../src/com/cloud/dc/dao/HostPodDaoImpl.java    |   2 +-
 .../dc/dao/StorageNetworkIpAddressDaoImpl.java  |   2 +-
 .../src/com/cloud/domain/dao/DomainDaoImpl.java |   2 +-
 .../src/com/cloud/host/dao/HostDaoImpl.java     |   4 +-
 .../com/cloud/network/dao/NetworkDaoImpl.java   |   2 +-
 .../com/cloud/network/dao/NetworkOpDaoImpl.java |   2 +-
 .../network/dao/NetworkServiceMapDaoImpl.java   |   2 +-
 .../PhysicalNetworkIsolationMethodDaoImpl.java  |   2 +-
 .../network/dao/PhysicalNetworkTagDaoImpl.java  |   2 +-
 .../dao/PhysicalNetworkTrafficTypeDaoImpl.java  |  10 +-
 .../cloud/network/dao/RouterNetworkDaoImpl.java |   2 +-
 .../security/dao/SecurityGroupVMMapDaoImpl.java |   2 +-
 .../network/vpc/dao/VpcServiceMapDaoImpl.java   |   2 +-
 .../offerings/dao/NetworkOfferingDaoImpl.java   |   2 +-
 .../dao/NetworkOfferingServiceMapDaoImpl.java   |   2 +-
 .../projects/dao/ProjectAccountDaoImpl.java     |   4 +-
 .../com/cloud/upgrade/dao/VersionDaoImpl.java   |   2 +-
 .../src/com/cloud/user/dao/AccountDaoImpl.java  |   2 +-
 .../src/com/cloud/vm/dao/VMInstanceDaoImpl.java |   4 +-
 .../affinity/dao/AffinityGroupVMMapDaoImpl.java |   4 +-
 .../endpoint/DefaultEndPointSelector.java       |  14 +-
 .../src/com/cloud/utils/db/GenericDaoBase.java  |   6 +-
 .../cloud/utils/db/GenericSearchBuilder.java    | 153 +---------
 .../db/src/com/cloud/utils/db/GroupBy.java      |  14 +-
 .../db/src/com/cloud/utils/db/JoinBuilder.java  | 113 ++++----
 .../db/src/com/cloud/utils/db/SearchBase.java   | 279 +++++++++++++++++++
 .../src/com/cloud/utils/db/SearchBuilder.java   |   1 -
 .../src/com/cloud/utils/db/SearchCriteria.java  |  15 +-
 .../src/com/cloud/utils/db/SearchCriteria2.java |  90 +++---
 .../jobs/dao/SyncQueueItemDaoImpl.java          |   2 +-
 .../jobs/impl/AsyncJobManagerImpl.java          |   8 +-
 .../com/cloud/storage/StorageManagerImpl.java   |   2 +-
 36 files changed, 461 insertions(+), 310 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
index c02bed0..e7eea6c 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineClusterDaoImpl.java
@@ -202,7 +202,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long>
     @Override
     public List<Long> listDisabledClusters(long zoneId, Long podId) {
         GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
-        clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+        clusterIdSearch.selectFields(clusterIdSearch.entity().getId());
         clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
         if(podId != null){
             clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
@@ -224,12 +224,12 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long>
     public List<Long> listClustersWithDisabledPods(long zoneId) {
 
         GenericSearchBuilder<EngineHostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
-        disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
+        disabledPodIdSearch.selectFields(disabledPodIdSearch.entity().getId());
         disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
         disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
 
         GenericSearchBuilder<EngineClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
-        clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+        clusterIdSearch.selectFields(clusterIdSearch.entity().getId());
         clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
         clusterIdSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
index 5ba65cc..4bbc601 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostDaoImpl.java
@@ -269,7 +269,7 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO, Long> implem
         AvailHypevisorInZone.done();
 
         HostsInStatusSearch = createSearchBuilder(Long.class);
-        HostsInStatusSearch.selectField(HostsInStatusSearch.entity().getId());
+        HostsInStatusSearch.selectFields(HostsInStatusSearch.entity().getId());
         HostsInStatusSearch.and("dc", HostsInStatusSearch.entity().getDataCenterId(), Op.EQ);
         HostsInStatusSearch.and("pod", HostsInStatusSearch.entity().getPodId(), Op.EQ);
         HostsInStatusSearch.and("cluster", HostsInStatusSearch.entity().getClusterId(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
index 638d0bd..7bf85d5 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/datacenter/entity/api/db/dao/EngineHostPodDaoImpl.java
@@ -138,7 +138,7 @@ public class EngineHostPodDaoImpl extends GenericDaoBase<EngineHostPodVO, Long>
     @Override
     public List<Long> listDisabledPods(long zoneId) {
         GenericSearchBuilder<EngineHostPodVO, Long> podIdSearch = createSearchBuilder(Long.class);
-        podIdSearch.selectField(podIdSearch.entity().getId());
+        podIdSearch.selectFields(podIdSearch.entity().getId());
         podIdSearch.and("dataCenterId", podIdSearch.entity().getDataCenterId(), Op.EQ);
         podIdSearch.and("allocationState", podIdSearch.entity().getAllocationState(), Op.EQ);
         podIdSearch.done();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
index 64bf1fe..d115ce9 100644
--- a/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/ClusterDaoImpl.java
@@ -94,7 +94,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
         ZoneClusterSearch.done();
 
         ClusterIdSearch = createSearchBuilder(Long.class);
-        ClusterIdSearch.selectField(ClusterIdSearch.entity().getId());
+        ClusterIdSearch.selectFields(ClusterIdSearch.entity().getId());
         ClusterIdSearch.and("dataCenterId", ClusterIdSearch.entity().getDataCenterId(), Op.EQ);
         ClusterIdSearch.done();
     }
@@ -196,7 +196,7 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
     @Override
     public List<Long> listDisabledClusters(long zoneId, Long podId) {
         GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
-        clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+        clusterIdSearch.selectFields(clusterIdSearch.entity().getId());
         clusterIdSearch.and("dataCenterId", clusterIdSearch.entity().getDataCenterId(), Op.EQ);
         if (podId != null) {
             clusterIdSearch.and("podId", clusterIdSearch.entity().getPodId(), Op.EQ);
@@ -217,12 +217,12 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
     public List<Long> listClustersWithDisabledPods(long zoneId) {
 
         GenericSearchBuilder<HostPodVO, Long> disabledPodIdSearch = _hostPodDao.createSearchBuilder(Long.class);
-        disabledPodIdSearch.selectField(disabledPodIdSearch.entity().getId());
+        disabledPodIdSearch.selectFields(disabledPodIdSearch.entity().getId());
         disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ);
         disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ);
 
         GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class);
-        clusterIdSearch.selectField(clusterIdSearch.entity().getId());
+        clusterIdSearch.selectFields(clusterIdSearch.entity().getId());
         clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER);
         clusterIdSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/dc/dao/HostPodDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/HostPodDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/HostPodDaoImpl.java
index 14b2931..f77deda 100644
--- a/engine/schema/src/com/cloud/dc/dao/HostPodDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/HostPodDaoImpl.java
@@ -57,7 +57,7 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H
         DataCenterIdSearch.done();
 
         PodIdSearch = createSearchBuilder(Long.class);
-        PodIdSearch.selectField(PodIdSearch.entity().getId());
+        PodIdSearch.selectFields(PodIdSearch.entity().getId());
         PodIdSearch.and("dataCenterId", PodIdSearch.entity().getDataCenterId(), Op.EQ);
         PodIdSearch.and("allocationState", PodIdSearch.entity().getAllocationState(), Op.EQ);
         PodIdSearch.done();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
index 782ee0d..ee1c3db 100755
--- a/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/StorageNetworkIpAddressDaoImpl.java
@@ -56,7 +56,7 @@ public class StorageNetworkIpAddressDaoImpl extends GenericDaoBase<StorageNetwor
 		countInUserIp.done();
 		
 		listInUseIp = createSearchBuilder(String.class);
-		listInUseIp.selectField(listInUseIp.entity().getIpAddress());
+		listInUseIp.selectFields(listInUseIp.entity().getIpAddress());
 		listInUseIp.and("rangeId", listInUseIp.entity().getRangeId(), Op.EQ);
 		listInUseIp.and("taken", listInUseIp.entity().getTakenAt(), Op.NNULL);
 		listInUseIp.done();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
index c84aa60..3d0588e 100644
--- a/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
+++ b/engine/schema/src/com/cloud/domain/dao/DomainDaoImpl.java
@@ -74,7 +74,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom
 		FindAllChildrenSearch.done();
 
 		FindIdsOfAllChildrenSearch = createSearchBuilder(Long.class);
-		FindIdsOfAllChildrenSearch.selectField(FindIdsOfAllChildrenSearch.entity().getId());
+		FindIdsOfAllChildrenSearch.selectFields(FindIdsOfAllChildrenSearch.entity().getId());
 		FindIdsOfAllChildrenSearch.and("path", FindIdsOfAllChildrenSearch.entity().getPath(), SearchCriteria.Op.LIKE);
 		FindIdsOfAllChildrenSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
index b373737..d0d3a5c 100755
--- a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
@@ -306,7 +306,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
         AvailHypevisorInZone.done();
 
         HostsInStatusSearch = createSearchBuilder(Long.class);
-        HostsInStatusSearch.selectField(HostsInStatusSearch.entity().getId());
+        HostsInStatusSearch.selectFields(HostsInStatusSearch.entity().getId());
         HostsInStatusSearch.and("dc", HostsInStatusSearch.entity().getDataCenterId(), Op.EQ);
         HostsInStatusSearch.and("pod", HostsInStatusSearch.entity().getPodId(), Op.EQ);
         HostsInStatusSearch.and("cluster", HostsInStatusSearch.entity().getClusterId(), Op.EQ);
@@ -370,7 +370,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
         HostsInClusterSearch.done();
 
         HostIdSearch = createSearchBuilder(Long.class);
-        HostIdSearch.selectField(HostIdSearch.entity().getId());
+        HostIdSearch.selectFields(HostIdSearch.entity().getId());
         HostIdSearch.and("dataCenterId", HostIdSearch.entity().getDataCenterId(), Op.EQ);
         HostIdSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
index 1b2c2bf..23ccba9 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -226,7 +226,7 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
         OfferingAccountNetworkSearch.done();
 
         GarbageCollectedSearch = createSearchBuilder(Long.class);
-        GarbageCollectedSearch.selectField(GarbageCollectedSearch.entity().getId());
+        GarbageCollectedSearch.selectFields(GarbageCollectedSearch.entity().getId());
         SearchBuilder<NetworkOpVO> join7 = _ntwkOpDao.createSearchBuilder();
         join7.and("activenics", join7.entity().getActiveNicsCount(), Op.EQ);
         join7.and("gc", join7.entity().isGarbageCollected(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/NetworkOpDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkOpDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkOpDaoImpl.java
index a3f54b7..18e2c80 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkOpDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkOpDaoImpl.java
@@ -39,7 +39,7 @@ public class NetworkOpDaoImpl extends GenericDaoBase<NetworkOpVO, Long> implemen
         super();
         
         ActiveNicsSearch = createSearchBuilder(Integer.class);
-        ActiveNicsSearch.selectField(ActiveNicsSearch.entity().getActiveNicsCount());
+        ActiveNicsSearch.selectFields(ActiveNicsSearch.entity().getActiveNicsCount());
         ActiveNicsSearch.and("network", ActiveNicsSearch.entity().getId(), Op.EQ);
         ActiveNicsSearch.done();
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
index 3cdd738..a4ebd8c 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
@@ -57,7 +57,7 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
         DistinctProvidersSearch.and("networkId", DistinctProvidersSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.and("service", DistinctProvidersSearch.entity().getService(), SearchCriteria.Op.EQ);
-        DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
+        DistinctProvidersSearch.selectFields(DistinctProvidersSearch.entity().getProvider());
         DistinctProvidersSearch.done();
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/PhysicalNetworkIsolationMethodDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkIsolationMethodDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkIsolationMethodDaoImpl.java
index 04508e7..0cebb48 100644
--- a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkIsolationMethodDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkIsolationMethodDaoImpl.java
@@ -35,7 +35,7 @@ public class PhysicalNetworkIsolationMethodDaoImpl extends GenericDaoBase<Physic
     protected PhysicalNetworkIsolationMethodDaoImpl() {
         super();
         IsolationMethodSearch = createSearchBuilder(String.class);
-        IsolationMethodSearch.selectField(IsolationMethodSearch.entity().getIsolationMethod());
+        IsolationMethodSearch.selectFields(IsolationMethodSearch.entity().getIsolationMethod());
         IsolationMethodSearch.and("physicalNetworkId", IsolationMethodSearch.entity().getPhysicalNetworkId(), Op.EQ);
         IsolationMethodSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
index c3e9f73..b38f67a 100644
--- a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTagDaoImpl.java
@@ -35,7 +35,7 @@ public class PhysicalNetworkTagDaoImpl extends GenericDaoBase<PhysicalNetworkTag
     protected PhysicalNetworkTagDaoImpl() {
         super();
         TagSearch = createSearchBuilder(String.class);
-        TagSearch.selectField(TagSearch.entity().getTag());
+        TagSearch.selectFields(TagSearch.entity().getTag());
         TagSearch.and("physicalNetworkId", TagSearch.entity().getPhysicalNetworkId(), Op.EQ);
         TagSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
index 7e47239..910616c 100755
--- a/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/PhysicalNetworkTrafficTypeDaoImpl.java
@@ -52,31 +52,31 @@ public class PhysicalNetworkTrafficTypeDaoImpl extends GenericDaoBase<PhysicalNe
         kvmAllFieldsSearch = createSearchBuilder(String.class);
         kvmAllFieldsSearch.and("physicalNetworkId", kvmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
         kvmAllFieldsSearch.and("trafficType", kvmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        kvmAllFieldsSearch.selectField(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
+        kvmAllFieldsSearch.selectFields(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
         kvmAllFieldsSearch.done();
 
         xenAllFieldsSearch = createSearchBuilder(String.class);
         xenAllFieldsSearch.and("physicalNetworkId", xenAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
         xenAllFieldsSearch.and("trafficType", xenAllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        xenAllFieldsSearch.selectField(xenAllFieldsSearch.entity().getXenNetworkLabel());
+        xenAllFieldsSearch.selectFields(xenAllFieldsSearch.entity().getXenNetworkLabel());
         xenAllFieldsSearch.done();
 
         vmWareAllFieldsSearch = createSearchBuilder(String.class);
         vmWareAllFieldsSearch.and("physicalNetworkId", vmWareAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
         vmWareAllFieldsSearch.and("trafficType", vmWareAllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        vmWareAllFieldsSearch.selectField(vmWareAllFieldsSearch.entity().getVmwareNetworkLabel());
+        vmWareAllFieldsSearch.selectFields(vmWareAllFieldsSearch.entity().getVmwareNetworkLabel());
         vmWareAllFieldsSearch.done();
         
         simulatorAllFieldsSearch = createSearchBuilder(String.class);
         simulatorAllFieldsSearch.and("physicalNetworkId", simulatorAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
         simulatorAllFieldsSearch.and("trafficType", simulatorAllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        simulatorAllFieldsSearch.selectField(simulatorAllFieldsSearch.entity().getSimulatorNetworkLabel());
+        simulatorAllFieldsSearch.selectFields(simulatorAllFieldsSearch.entity().getSimulatorNetworkLabel());
         simulatorAllFieldsSearch.done();
         
         ovmAllFieldsSearch = createSearchBuilder(String.class);
         ovmAllFieldsSearch.and("physicalNetworkId", ovmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
         ovmAllFieldsSearch.and("trafficType", ovmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
-        ovmAllFieldsSearch.selectField(ovmAllFieldsSearch.entity().getSimulatorNetworkLabel());
+        ovmAllFieldsSearch.selectFields(ovmAllFieldsSearch.entity().getSimulatorNetworkLabel());
         ovmAllFieldsSearch.done();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java b/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
index b0b633c..6b0c6ef 100644
--- a/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
@@ -36,7 +36,7 @@ public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long>
         super();
 
         RouterNetworksSearch = createSearchBuilder(Long.class);
-        RouterNetworksSearch.selectField(RouterNetworksSearch.entity().getNetworkId());
+        RouterNetworksSearch.selectFields(RouterNetworksSearch.entity().getNetworkId());
         RouterNetworksSearch.and("routerId", RouterNetworksSearch.entity().getRouterId(), Op.EQ);
         RouterNetworksSearch.done();
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java b/engine/schema/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
index 46135d1..26d5a42 100644
--- a/engine/schema/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java
@@ -59,7 +59,7 @@ public class SecurityGroupVMMapDaoImpl extends GenericDaoBase<SecurityGroupVMMap
 
         ListVmIdBySecurityGroup = createSearchBuilder(Long.class);
         ListVmIdBySecurityGroup.and("securityGroupId", ListVmIdBySecurityGroup.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
-        ListVmIdBySecurityGroup.selectField(ListVmIdBySecurityGroup.entity().getInstanceId());
+        ListVmIdBySecurityGroup.selectFields(ListVmIdBySecurityGroup.entity().getInstanceId());
         ListVmIdBySecurityGroup.done();
         
         ListBySecurityGroup = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/network/vpc/dao/VpcServiceMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/VpcServiceMapDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/VpcServiceMapDaoImpl.java
index a992181..41e8d91 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/VpcServiceMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/VpcServiceMapDaoImpl.java
@@ -56,7 +56,7 @@ public class VpcServiceMapDaoImpl extends GenericDaoBase<VpcServiceMapVO, Long>
         DistinctProvidersSearch = createSearchBuilder(String.class);
         DistinctProvidersSearch.and("vpcId", DistinctProvidersSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
-        DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
+        DistinctProvidersSearch.selectFields(DistinctProvidersSearch.entity().getProvider());
         DistinctProvidersSearch.done();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
index ef8237a..8432473 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
@@ -76,7 +76,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
         AllFieldsSearch.done();
 
         UpgradeSearch = createSearchBuilder(Long.class);
-        UpgradeSearch.selectField(UpgradeSearch.entity().getId());
+        UpgradeSearch.selectFields(UpgradeSearch.entity().getId());
         UpgradeSearch.and("physicalNetworkId", UpgradeSearch.entity().getId(), Op.NEQ);
         UpgradeSearch.and("physicalNetworkId", UpgradeSearch.entity().isSystemOnly(), Op.EQ);
         UpgradeSearch.and("trafficType", UpgradeSearch.entity().getTrafficType(), Op.EQ);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java
index 7282443..d2fbfe9 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingServiceMapDaoImpl.java
@@ -72,7 +72,7 @@ public class NetworkOfferingServiceMapDaoImpl extends GenericDaoBase<NetworkOffe
         DistinctProvidersSearch = createSearchBuilder(String.class);
         DistinctProvidersSearch.and("offId", DistinctProvidersSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
-        DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
+        DistinctProvidersSearch.selectFields(DistinctProvidersSearch.entity().getProvider());
         DistinctProvidersSearch.done();
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/projects/dao/ProjectAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/projects/dao/ProjectAccountDaoImpl.java b/engine/schema/src/com/cloud/projects/dao/ProjectAccountDaoImpl.java
index b089e58..416994f 100644
--- a/engine/schema/src/com/cloud/projects/dao/ProjectAccountDaoImpl.java
+++ b/engine/schema/src/com/cloud/projects/dao/ProjectAccountDaoImpl.java
@@ -50,13 +50,13 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long
         AllFieldsSearch.done();
 
         AdminSearch = createSearchBuilder(Long.class);
-        AdminSearch.selectField(AdminSearch.entity().getProjectId());
+        AdminSearch.selectFields(AdminSearch.entity().getProjectId());
         AdminSearch.and("role", AdminSearch.entity().getAccountRole(), Op.EQ);
         AdminSearch.and("accountId", AdminSearch.entity().getAccountId(), Op.EQ);
         AdminSearch.done();
 
         ProjectAccountSearch = createSearchBuilder(Long.class);
-        ProjectAccountSearch.selectField(ProjectAccountSearch.entity().getProjectAccountId());
+        ProjectAccountSearch.selectFields(ProjectAccountSearch.entity().getProjectAccountId());
         ProjectAccountSearch.and("accountId", ProjectAccountSearch.entity().getAccountId(), Op.EQ);
         ProjectAccountSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java b/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
index 3b2ed7e..2cdb5ec 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
@@ -51,7 +51,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
         super();
 
         CurrentVersionSearch = createSearchBuilder(String.class);
-        CurrentVersionSearch.selectField(CurrentVersionSearch.entity().getVersion());
+        CurrentVersionSearch.selectFields(CurrentVersionSearch.entity().getVersion());
         CurrentVersionSearch.and("step", CurrentVersionSearch.entity().getStep(), Op.EQ);
         CurrentVersionSearch.done();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/user/dao/AccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/dao/AccountDaoImpl.java b/engine/schema/src/com/cloud/user/dao/AccountDaoImpl.java
index aa67e86..41f1f73 100755
--- a/engine/schema/src/com/cloud/user/dao/AccountDaoImpl.java
+++ b/engine/schema/src/com/cloud/user/dao/AccountDaoImpl.java
@@ -96,7 +96,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
         NonProjectAccountSearch.done();
 
         AccountIdsSearch = createSearchBuilder(Long.class);
-        AccountIdsSearch.selectField(AccountIdsSearch.entity().getId());
+        AccountIdsSearch.selectFields(AccountIdsSearch.entity().getId());
         AccountIdsSearch.and("ids", AccountIdsSearch.entity().getDomainId(), Op.IN);
         AccountIdsSearch.done();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index 3a7dde7..cf8e0a8 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -198,7 +198,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
         HostNameSearch.done();
 
         FindIdsOfVirtualRoutersByAccount = createSearchBuilder(Long.class);
-        FindIdsOfVirtualRoutersByAccount.selectField(FindIdsOfVirtualRoutersByAccount.entity().getId());
+        FindIdsOfVirtualRoutersByAccount.selectFields(FindIdsOfVirtualRoutersByAccount.entity().getId());
         FindIdsOfVirtualRoutersByAccount.and("account", FindIdsOfVirtualRoutersByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
         FindIdsOfVirtualRoutersByAccount.and("type", FindIdsOfVirtualRoutersByAccount.entity().getType(), SearchCriteria.Op.EQ);
         FindIdsOfVirtualRoutersByAccount.and("state", FindIdsOfVirtualRoutersByAccount.entity().getState(), SearchCriteria.Op.NIN);
@@ -233,7 +233,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
         nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
 
         DistinctHostNameSearch = createSearchBuilder(String.class);
-        DistinctHostNameSearch.selectField(DistinctHostNameSearch.entity().getHostName());
+        DistinctHostNameSearch.selectFields(DistinctHostNameSearch.entity().getHostName());
 
         DistinctHostNameSearch.and("types", DistinctHostNameSearch.entity().getType(), SearchCriteria.Op.IN);
         DistinctHostNameSearch.and("removed", DistinctHostNameSearch.entity().getRemoved(), SearchCriteria.Op.NULL);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/schema/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java b/engine/schema/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
index 89dfa5a..ad8f4f0 100644
--- a/engine/schema/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/affinity/dao/AffinityGroupVMMapDaoImpl.java
@@ -56,7 +56,7 @@ public class AffinityGroupVMMapDaoImpl extends GenericDaoBase<AffinityGroupVMMap
         ListVmIdByAffinityGroup = createSearchBuilder(Long.class);
         ListVmIdByAffinityGroup.and("affinityGroupId", ListVmIdByAffinityGroup.entity().getAffinityGroupId(),
                 SearchCriteria.Op.EQ);
-        ListVmIdByAffinityGroup.selectField(ListVmIdByAffinityGroup.entity().getInstanceId());
+        ListVmIdByAffinityGroup.selectFields(ListVmIdByAffinityGroup.entity().getInstanceId());
         ListVmIdByAffinityGroup.done();
 
         ListByAffinityGroup = createSearchBuilder();
@@ -89,7 +89,7 @@ public class AffinityGroupVMMapDaoImpl extends GenericDaoBase<AffinityGroupVMMap
         ListAffinityGroupIdByVm = createSearchBuilder(Long.class);
         ListAffinityGroupIdByVm.and("instanceId", ListAffinityGroupIdByVm.entity().getInstanceId(),
                 SearchCriteria.Op.EQ);
-        ListAffinityGroupIdByVm.selectField(ListAffinityGroupIdByVm.entity().getAffinityGroupId());
+        ListAffinityGroupIdByVm.selectFields(ListAffinityGroupIdByVm.entity().getAffinityGroupId());
         ListAffinityGroupIdByVm.done();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
index 65524e0..1e4101e 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
@@ -27,15 +27,16 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
-import org.apache.cloudstack.storage.RemoteHostEndPoint;
 import org.apache.cloudstack.storage.LocalHostEndpoint;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
+import org.apache.cloudstack.storage.RemoteHostEndPoint;
 
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
@@ -44,10 +45,9 @@ import com.cloud.host.dao.HostDao;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
 import com.cloud.utils.db.DB;
-import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 @Component
@@ -55,7 +55,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
     private static final Logger s_logger = Logger.getLogger(DefaultEndPointSelector.class);
     @Inject
     HostDao hostDao;
-    private String findOneHostOnPrimaryStorage = "select h.id from host h, storage_pool_host_ref s  where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and" +
+    private final String findOneHostOnPrimaryStorage = "select h.id from host h, storage_pool_host_ref s  where h.status = 'Up' and h.type = 'Routing' and h.resource_state = 'Enabled' and" +
             " h.id = s.host_id and s.pool_id = ? ";
 
     protected boolean moveBetweenPrimaryImage(DataStore srcStore, DataStore destStore) {
@@ -261,7 +261,7 @@ public class DefaultEndPointSelector implements EndPointSelector {
             SearchCriteria2<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
             sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, store.getScope().getScopeId());
             sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-            List<HostVO> hosts = sc.find();
+            List<HostVO> hosts = sc.list();
             for (HostVO host : hosts) {
                 endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                         host.getPublicIpAddress()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
index fd56171..ad8c770 100755
--- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@@ -928,7 +928,6 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
     }
 
     @Override @DB(txn=false)
-    @SuppressWarnings("unchecked")
     public T findByUuid(final String uuid) {
         SearchCriteria<T> sc = createSearchCriteria();
         sc.addAnd("uuid", SearchCriteria.Op.EQ, uuid);
@@ -936,7 +935,6 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
     }
 
     @Override @DB(txn=false)
-    @SuppressWarnings("unchecked")
     public T findByUuidIncludingRemoved(final String uuid) {
         SearchCriteria<T> sc = createSearchCriteria();
         sc.addAnd("uuid", SearchCriteria.Op.EQ, uuid);
@@ -1044,7 +1042,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
 
     @DB(txn=false)
     protected List<Object> addGroupBy(final StringBuilder sql, SearchCriteria<?> sc) {
-        Pair<GroupBy<?, ?>, List<Object>> groupBys = sc.getGroupBy();
+        Pair<GroupBy<?, ?, ?>, List<Object>> groupBys = sc.getGroupBy();
         if (groupBys != null) {
             groupBys.first().toSql(sql);
             return groupBys.second();
@@ -1368,7 +1366,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
             Object obj = entry.getValue();
 
             EcInfo ec = (EcInfo)attr.attache;
-            Enumeration en = null;
+            Enumeration<?> en = null;
             if (ec.rawClass == null) {
                 en = Collections.enumeration(Arrays.asList((Object[])obj));
             } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
index 732527a..16c77f1 100755
--- a/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
@@ -19,14 +19,9 @@ package com.cloud.utils.db;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
-import java.util.UUID;
-
-import net.sf.cglib.proxy.Factory;
 
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria.SelectType;
 
 /**
  * GenericSearchBuilder is used to build a search based on a VO object
@@ -37,34 +32,22 @@ import com.cloud.utils.db.SearchCriteria.SelectType;
  * @param <K> Result object that should contain the results.
  */
 public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
-    @SuppressWarnings("unchecked")
     protected GenericSearchBuilder(Class<T> entityType, Class<K> resultType) {
         super(entityType, resultType);
     }
     
-    public T entity() {
-        return _entity;
-    }
-    
-    protected Attribute getSpecifiedAttribute() {
-        if (_entity == null || _specifiedAttrs == null || _specifiedAttrs.size() != 1) {
-            throw new RuntimeException("Now now, better specify an attribute or else we can't help you");
-        }
-        return _specifiedAttrs.get(0);
-    }
-
-    public GenericSearchBuilder<T, K> selectField(Object... useless) {
+    public GenericSearchBuilder<T, K> selectFields(Object... useless) {
         if (_entity == null) {
             throw new RuntimeException("SearchBuilder cannot be modified once it has been setup");
         }
         if (_specifiedAttrs.size() <= 0) {
             throw new RuntimeException("You didn't specify any attributes");
         }
-   
+
         if (_selects == null) {
             _selects = new ArrayList<Select>();
         }
-        
+
         for (Attribute attr : _specifiedAttrs) {
             Field field = null;
             try {
@@ -75,12 +58,12 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
             }
             _selects.add(new Select(Func.NATIVE, attr, field, null));
         }
-        
+
         _specifiedAttrs.clear();
-        
+
         return this;
     }
-    
+
     /**
      * Specifies the field to select.
      * 
@@ -130,13 +113,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
     
-    @Override
-    protected void set(String name) {
-        Attribute attr = _attrs.get(name);
-        assert (attr != null) : "Searching for a field that's not there: " + name;
-        _specifiedAttrs.add(attr);
-    }
-   
     /**
      * Adds an AND condition to the SearchBuilder.
      * 
@@ -155,11 +131,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
-    public Preset and(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " AND ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
     public GenericSearchBuilder<T, K> and() {
         constructCondition(null, " AND ", null, null);
         return this;
@@ -182,10 +153,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return and(name, useless, op);
     }
 
-    public Preset where(Object useless, Op op) {
-        return and(useless, op);
-    }
-
     public GenericSearchBuilder<T, K> left(String name, Object useless, Op op) {
         constructCondition(name, " ( ", _specifiedAttrs.get(0), op);
         return this;
@@ -196,19 +163,10 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
-    public Preset left(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
     public GenericSearchBuilder<T, K> op(Object useless, Op op, String name) {
         return left(useless, op, name);
     }
 
-    public Preset op(Object useless, Op op) {
-        return left(useless, op);
-    }
-
     public GenericSearchBuilder<T, K> op(String name, Object useless, Op op) {
         return left(name, useless, op);
     }
@@ -221,19 +179,12 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return left(name, useless, op);
     }
     
-    public Preset openParen(Object useless, Op op) {
-        return left(useless, op);
-    }
-
-    public GroupBy<T, K> groupBy(Object... useless) {
+    public GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy(Object... useless) {
         assert _groupBy == null : "Can't do more than one group bys";
-        _groupBy = new GroupBy<T, K>(this);
+        GroupBy<GenericSearchBuilder<T, K>, T, K> groupBy = new GroupBy<GenericSearchBuilder<T, K>, T, K>(this);
+        _groupBy = groupBy;
         
-        return _groupBy;
-    }
-    
-    protected List<Attribute> getSpecifiedAttributes() {
-        return _specifiedAttrs;
+        return groupBy;
     }
     
     /**
@@ -254,11 +205,6 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
 
-    public Preset or(Object useless, Op op) {
-        Condition condition = constructCondition(UUID.randomUUID().toString(), " OR ", _specifiedAttrs.get(0), op);
-        return new Preset(this, condition);
-    }
-
     public GenericSearchBuilder<T, K> join(String name, GenericSearchBuilder<?, ?> builder, Object useless, Object useless2, JoinBuilder.JoinType joinType) {
         assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
         assert _specifiedAttrs.size() == 1 : "You didn't select the attribute.";
@@ -266,9 +212,9 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         assert builder._specifiedAttrs.size() == 1 : "You didn't select the attribute.";
         assert builder != this : "You can't add yourself, can you?  Really think about it!";
         
-        JoinBuilder<GenericSearchBuilder<?, ?>> t = new JoinBuilder<GenericSearchBuilder<?, ?>>(builder, _specifiedAttrs.get(0), builder._specifiedAttrs.get(0), joinType);
+        JoinBuilder<SearchBase<?, ?>> t = new JoinBuilder<SearchBase<?, ?>>(builder, _specifiedAttrs.get(0), builder._specifiedAttrs.get(0), joinType);
         if (_joins == null) {
-        	_joins = new HashMap<String, JoinBuilder<GenericSearchBuilder<?, ?>>>();
+            _joins = new HashMap<String, JoinBuilder<SearchBase<?, ?>>>();
         }
         _joins.put(name, t);
         
@@ -277,29 +223,7 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return this;
     }
     
-    protected Condition constructCondition(String conditionName, String cond, Attribute attr, Op op) {
-        assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
-        assert op == null || _specifiedAttrs.size() == 1 : "You didn't select the attribute.";
-        assert op != Op.SC : "Call join";
-        
-        Condition condition = new Condition(conditionName, cond, attr, op);
-        _conditions.add(condition);
-        _specifiedAttrs.clear();
-        return condition;
-    }
 
-    /**
-     * creates the SearchCriteria so the actual values can be filled in.
-     * 
-     * @return SearchCriteria
-     */
-    public SearchCriteria<K> create() {
-        if (_entity != null) {
-            done();
-        }
-        return new SearchCriteria<K>(this);
-    }
-    
     public SearchCriteria<K> create(String name, Object... values) {
         SearchCriteria<K> sc = create();
         sc.setParameters(name, values);
@@ -320,62 +244,11 @@ public class GenericSearchBuilder<T, K> extends SearchBase<T, K> {
         return right();
     }
     
-    public SelectType getSelectType() {
-        return _selectType;
-    }
-    
     /**
      * Marks the SearchBuilder as completed in building the search conditions.
      */
     public synchronized void done() {
-        if (_entity != null) {
-            Factory factory = (Factory)_entity;
-            factory.setCallback(0, null);
-            _entity = null;
-        }
-        
-        if (_joins != null) {
-        	for (JoinBuilder<GenericSearchBuilder<?, ?>> join : _joins.values()) {
-        		join.getT().done();
-            }
-        }
-        
-        if (_selects == null || _selects.size() == 0) {
-            _selectType = SelectType.Entity;
-            assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
-            return;
-        }
-        
-        for (Select select : _selects) {
-            if (select.field == null) {
-                assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
-                _selectType = SelectType.Single;
-                return;
-            }
-            if (select.func != null) {
-                _selectType = SelectType.Result;
-                return;
-            }
-        }
-        
-        _selectType = SelectType.Fields;
+        super.finalize();
     }
     
-    public class Preset {
-        GenericSearchBuilder<T, K> builder;
-        Condition condition;
-
-        protected Preset(GenericSearchBuilder<T, K> builder, Condition condition) {
-            this.builder = builder;
-            this.condition = condition;
-        }
-
-        public GenericSearchBuilder<T, K> values(Object... params) {
-            if (condition.op.getParams() > 0 && condition.op.params != params.length) {
-                throw new RuntimeException("The # of parameters set " + params.length + " does not match # of parameters required by " + condition.op);
-            }
-            condition.setPresets(params);
-            return builder;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/GroupBy.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/GroupBy.java b/framework/db/src/com/cloud/utils/db/GroupBy.java
index 3b9cd19..b3f88da 100644
--- a/framework/db/src/com/cloud/utils/db/GroupBy.java
+++ b/framework/db/src/com/cloud/utils/db/GroupBy.java
@@ -23,12 +23,12 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
 
-public class GroupBy<T, R> {
-    GenericSearchBuilder<T, R> _builder;
+public class GroupBy<J extends SearchBase<T, R>, T, R> {
+    J _builder;
     List<Pair<Func, Attribute>> _groupBys;
     Having _having;
     
-    public GroupBy(GenericSearchBuilder<T, R> builder) {
+    public GroupBy(J builder) {
         _builder = builder;
         _groupBys = new ArrayList<Pair<Func, Attribute>>();
         _having = null;
@@ -38,19 +38,19 @@ public class GroupBy<T, R> {
         _builder.getSpecifiedAttributes().clear();
     }
     
-    public GroupBy<T, R> group(Object useless) {
+    public GroupBy<J, T, R> group(Object useless) {
         _groupBys.add(new Pair<Func, Attribute>(null, _builder.getSpecifiedAttributes().get(0)));
         _builder.getSpecifiedAttributes().clear();
-        return this; 
+        return this;
     }
     
-    public GroupBy<T, R> group(Func func, Object useless) {
+    public GroupBy<J, T, R> group(Func func, Object useless) {
         _groupBys.add(new Pair<Func, Attribute>(func, _builder.getSpecifiedAttributes().get(0)));
         _builder.getSpecifiedAttributes().clear();
         return this;
     }
     
-    public GenericSearchBuilder<T, R> having(Func func, Object obj, Op op, Object value) {
+    public J having(Func func, Object obj, Op op, Object value) {
         assert(_having == null) : "You can only specify one having in a group by";
         List<Attribute> attrs = _builder.getSpecifiedAttributes();
         assert attrs.size() == 1 : "You didn't specified an attribute";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/JoinBuilder.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/JoinBuilder.java b/framework/db/src/com/cloud/utils/db/JoinBuilder.java
index c4920c4..f770ac4 100644
--- a/framework/db/src/com/cloud/utils/db/JoinBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/JoinBuilder.java
@@ -16,64 +16,65 @@
 // under the License.
 package com.cloud.utils.db;
 
-
 public class JoinBuilder<T> {
-	
-	public enum JoinType {
-	     INNER ("INNER JOIN"),
-	     LEFT ("LEFT JOIN"),
-	     RIGHT ("RIGHT JOIN"),
-	     RIGHTOUTER ("RIGHT OUTER JOIN"),
-	     LEFTOUTER ("LEFT OUTER JOIN");
-	     
-	     private final String _name;
-	     
-	     JoinType(String name) {
-	            _name = name;
-	     }
-	     
-	     public String getName() { return _name; }
-	}
 
-	
-	private T t;
-	private JoinType type;
-	private Attribute firstAttribute;
-	private Attribute secondAttribute;
-	
-	public JoinBuilder(T t, Attribute firstAttribute,
-			Attribute secondAttribute, JoinType type) {
-		this.t = t;
-		this.firstAttribute = firstAttribute;
-		this.secondAttribute = secondAttribute;
-		this.type = type;
-	}
-	
-	public T getT() {
-		return t;
-	}
-	public void setT(T t) {
-		this.t = t;
-	}
-	public JoinType getType() {
-		return type;
-	}
-	public void setType(JoinType type) {
-		this.type = type;
-	}
-	public Attribute getFirstAttribute() {
-		return firstAttribute;
-	}
-	public void setFirstAttribute(Attribute firstAttribute) {
-		this.firstAttribute = firstAttribute;
-	}
-	public Attribute getSecondAttribute() {
-		return secondAttribute;
-	}
-	public void setSecondAttribute(Attribute secondAttribute) {
-		this.secondAttribute = secondAttribute;
-	}
+    public enum JoinType {
+        INNER("INNER JOIN"),
+        LEFT("LEFT JOIN"),
+        RIGHT("RIGHT JOIN"),
+        RIGHTOUTER("RIGHT OUTER JOIN"),
+        LEFTOUTER("LEFT OUTER JOIN");
 
-}
+        private final String _name;
+
+        JoinType(String name) {
+            _name = name;
+        }
+
+        public String getName() {
+            return _name;
+        }
+    }
+
+    private final T t;
+    private JoinType type;
+    private Attribute firstAttribute;
+    private Attribute secondAttribute;
+
+    public JoinBuilder(T t, Attribute firstAttribute,
+            Attribute secondAttribute, JoinType type) {
+        this.t = t;
+        this.firstAttribute = firstAttribute;
+        this.secondAttribute = secondAttribute;
+        this.type = type;
+    }
+
+    public T getT() {
+        return t;
+    }
 
+    public JoinType getType() {
+        return type;
+    }
 
+    public void setType(JoinType type) {
+        this.type = type;
+    }
+
+    public Attribute getFirstAttribute() {
+        return firstAttribute;
+    }
+
+    public void setFirstAttribute(Attribute firstAttribute) {
+        this.firstAttribute = firstAttribute;
+    }
+
+    public Attribute getSecondAttribute() {
+        return secondAttribute;
+    }
+
+    public void setSecondAttribute(Attribute secondAttribute) {
+        this.secondAttribute = secondAttribute;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/SearchBase.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/SearchBase.java b/framework/db/src/com/cloud/utils/db/SearchBase.java
new file mode 100644
index 0000000..b28ac17
--- /dev/null
+++ b/framework/db/src/com/cloud/utils/db/SearchBase.java
@@ -0,0 +1,279 @@
+package com.cloud.utils.db;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.Transient;
+
+import net.sf.cglib.proxy.Factory;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.SearchCriteria.SelectType;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public abstract class SearchBase<T, K> {
+
+    final Map<String, Attribute> _attrs;
+    final Class<T> _entityBeanType;
+    final Class<K> _resultType;
+    final GenericDaoBase<? extends T, ? extends Serializable> _dao;
+
+    final ArrayList<Condition> _conditions;
+    final ArrayList<Attribute> _specifiedAttrs;
+
+    protected HashMap<String, JoinBuilder<SearchBase<?, ?>>> _joins;
+    protected ArrayList<Select> _selects;
+    protected GroupBy<? extends SearchBase<T, K>, T, K> _groupBy = null;
+    protected SelectType _selectType;
+    T _entity;
+
+    SearchBase(Class<T> entityType, Class<K> resultType) {
+        _dao = (GenericDaoBase<? extends T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
+        if (_dao == null) {
+            throw new CloudRuntimeException("Unable to find DAO for " + entityType);
+        }
+
+        _entityBeanType = entityType;
+        _resultType = resultType;
+        _attrs = _dao.getAllAttributes();
+
+        _entity = _dao.createSearchEntity(new Interceptor());
+        _conditions = new ArrayList<Condition>();
+        _joins = null;
+        _specifiedAttrs = new ArrayList<Attribute>();
+    }
+
+    public SelectType getSelectType() {
+        return _selectType;
+    }
+
+    protected void set(String name) {
+        Attribute attr = _attrs.get(name);
+        assert (attr != null) : "Searching for a field that's not there: " + name;
+        _specifiedAttrs.add(attr);
+    }
+
+    public T entity() {
+        return _entity;
+    }
+
+    protected Attribute getSpecifiedAttribute() {
+        if (_entity == null || _specifiedAttrs == null || _specifiedAttrs.size() != 1) {
+            throw new RuntimeException("Now now, better specify an attribute or else we can't help you");
+        }
+        return _specifiedAttrs.get(0);
+    }
+
+    protected List<Attribute> getSpecifiedAttributes() {
+        return _specifiedAttrs;
+    }
+
+    protected Condition constructCondition(String conditionName, String cond, Attribute attr, Op op) {
+        assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
+        assert op == null || _specifiedAttrs.size() == 1 : "You didn't select the attribute.";
+        assert op != Op.SC : "Call join";
+
+        Condition condition = new Condition(conditionName, cond, attr, op);
+        _conditions.add(condition);
+        _specifiedAttrs.clear();
+        return condition;
+    }
+
+    /**
+     * creates the SearchCriteria so the actual values can be filled in.
+     * 
+     * @return SearchCriteria
+     */
+    public SearchCriteria<K> create() {
+        if (_entity != null) {
+            finalize();
+        }
+        return new SearchCriteria<K>(this);
+    }
+
+    /**
+     * Marks the SearchBuilder as completed in building the search conditions.
+     */
+    @Override
+    public synchronized void finalize() {
+        if (_entity != null) {
+            Factory factory = (Factory)_entity;
+            factory.setCallback(0, null);
+            _entity = null;
+        }
+
+        if (_joins != null) {
+            for (JoinBuilder<SearchBase<?, ?>> join : _joins.values()) {
+                join.getT().finalize();
+            }
+        }
+
+        if (_selects == null || _selects.size() == 0) {
+            _selectType = SelectType.Entity;
+            assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
+            return;
+        }
+
+        for (Select select : _selects) {
+            if (select.field == null) {
+                assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
+                _selectType = SelectType.Single;
+                return;
+            }
+            if (select.func != null) {
+                _selectType = SelectType.Result;
+                return;
+            }
+        }
+
+        _selectType = SelectType.Fields;
+    }
+
+    protected static class Condition {
+        protected final String name;
+        protected final String cond;
+        protected final Op op;
+        protected final Attribute attr;
+        protected Object[] presets;
+
+        protected Condition(String name) {
+            this(name, null, null, null);
+        }
+
+        public Condition(String name, String cond, Attribute attr, Op op) {
+            this.name = name;
+            this.attr = attr;
+            this.cond = cond;
+            this.op = op;
+            this.presets = null;
+        }
+
+        public boolean isPreset() {
+            return presets != null;
+        }
+
+        public void setPresets(Object... presets) {
+            this.presets = presets;
+        }
+
+        public Object[] getPresets() {
+            return presets;
+        }
+
+        public void toSql(StringBuilder sql, Object[] params, int count) {
+            if (count > 0) {
+                sql.append(cond);
+            }
+
+            if (op == null) {
+                return;
+            }
+
+            if (op == Op.SC) {
+                sql.append(" (").append(((SearchCriteria<?>)params[0]).getWhereClause()).append(") ");
+                return;
+            }
+
+            if (attr == null) {
+                return;
+            }
+
+            sql.append(attr.table).append(".").append(attr.columnName).append(op.toString());
+            if (op == Op.IN && params.length == 1) {
+                sql.delete(sql.length() - op.toString().length(), sql.length());
+                sql.append("=?");
+            } else if (op == Op.NIN && params.length == 1) {
+                sql.delete(sql.length() - op.toString().length(), sql.length());
+                sql.append("!=?");
+            } else if (op.getParams() == -1) {
+                for (int i = 0; i < params.length; i++) {
+                    sql.insert(sql.length() - 2, "?,");
+                }
+                sql.delete(sql.length() - 3, sql.length() - 2); // remove the last ,
+            } else if (op == Op.EQ && (params == null || params.length == 0 || params[0] == null)) {
+                sql.delete(sql.length() - 4, sql.length());
+                sql.append(" IS NULL ");
+            } else if (op == Op.NEQ && (params == null || params.length == 0 || params[0] == null)) {
+                sql.delete(sql.length() - 5, sql.length());
+                sql.append(" IS NOT NULL ");
+            } else {
+                if ((op.getParams() != 0 || params != null) && (params.length != op.getParams())) {
+                    throw new RuntimeException("Problem with condition: " + name);
+                }
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            return name.hashCode();
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (!(obj instanceof Condition)) {
+                return false;
+            }
+
+            Condition condition = (Condition)obj;
+            return name.equals(condition.name);
+        }
+    }
+
+    protected static class Select {
+        public Func func;
+        public Attribute attr;
+        public Object[] params;
+        public Field field;
+
+        protected Select() {
+        }
+
+        public Select(Func func, Attribute attr, Field field, Object[] params) {
+            this.func = func;
+            this.attr = attr;
+            this.params = params;
+            this.field = field;
+        }
+    }
+
+    protected class Interceptor implements MethodInterceptor {
+        @Override
+        public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+            String name = method.getName();
+            if (method.getAnnotation(Transient.class) == null) {
+                if (name.startsWith("get")) {
+                    String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4);
+                    set(fieldName);
+                    return null;
+                } else if (name.startsWith("is")) {
+                    String fieldName = Character.toLowerCase(name.charAt(2)) + name.substring(3);
+                    set(fieldName);
+                    return null;
+                } else {
+                    Column ann = method.getAnnotation(Column.class);
+                    if (ann != null) {
+                        String colName = ann.name();
+                        for (Map.Entry<String, Attribute> attr : _attrs.entrySet()) {
+                            if (colName.equals(attr.getValue().columnName)) {
+                                set(attr.getKey());
+                                return null;
+                            }
+                        }
+                    }
+                    throw new RuntimeException("Perhaps you need to make the method start with get or is: " + method);
+                }
+            }
+            return methodProxy.invokeSuper(object, args);
+        }
+
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/SearchBuilder.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/SearchBuilder.java b/framework/db/src/com/cloud/utils/db/SearchBuilder.java
index 8410b01..a56ec1b 100755
--- a/framework/db/src/com/cloud/utils/db/SearchBuilder.java
+++ b/framework/db/src/com/cloud/utils/db/SearchBuilder.java
@@ -56,7 +56,6 @@ package com.cloud.utils.db;
  */
 public class SearchBuilder<T> extends GenericSearchBuilder<T, T> {
     
-    @SuppressWarnings("unchecked")
     public SearchBuilder(Class<T> entityType) {
         super(entityType, entityType);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/SearchCriteria.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/SearchCriteria.java b/framework/db/src/com/cloud/utils/db/SearchCriteria.java
index ba4a0fd..a1f6408 100755
--- a/framework/db/src/com/cloud/utils/db/SearchCriteria.java
+++ b/framework/db/src/com/cloud/utils/db/SearchCriteria.java
@@ -113,12 +113,13 @@ public class SearchCriteria<K> {
     private int _counter;
     private HashMap<String, JoinBuilder<SearchCriteria<?>>> _joins;
     private final ArrayList<Select> _selects;
-    private final GroupBy<?, K> _groupBy;
+    private final GroupBy<? extends SearchBase<?, K>, ?, K> _groupBy;
     private final List<Object> _groupByValues;
     private final Class<K> _resultType;
     private final SelectType _selectType;
 
-    protected SearchCriteria(final Map<String, Attribute> attrs, ArrayList<GenericSearchBuilder.Condition> conditions, ArrayList<Select> selects, SelectType selectType, Class<K> resultType, HashMap<String, Object[]> params) {
+    protected SearchCriteria(Map<String, Attribute> attrs, ArrayList<Condition> conditions, ArrayList<Select> selects, SelectType selectType, Class<K> resultType,
+            HashMap<String, Object[]> params) {
         this._attrs = attrs;
         this._conditions = conditions;
         this._selects = selects;
@@ -132,7 +133,7 @@ public class SearchCriteria<K> {
         this._groupByValues = null;
     }
 
-    protected SearchCriteria(GenericSearchBuilder<?, K> sb) {
+    protected SearchCriteria(SearchBase<?, K> sb) {
         this._attrs = sb._attrs;
         this._conditions = sb._conditions;
         this._additionals = new ArrayList<Condition>();
@@ -140,8 +141,8 @@ public class SearchCriteria<K> {
         this._joins = null;
         if (sb._joins != null) {
             _joins = new HashMap<String, JoinBuilder<SearchCriteria<?>>>(sb._joins.size());
-            for (Map.Entry<String, JoinBuilder<GenericSearchBuilder<?, ?>>> entry : sb._joins.entrySet()) {
-                JoinBuilder<GenericSearchBuilder<?, ?>> value =  entry.getValue();
+            for (Map.Entry<String, JoinBuilder<SearchBase<?, ?>>> entry : sb._joins.entrySet()) {
+                JoinBuilder<SearchBase<?, ?>> value = entry.getValue();
                 _joins.put(entry.getKey(), new JoinBuilder<SearchCriteria<?>>(value.getT().create(),value.getFirstAttribute(), value.getSecondAttribute(), value.getType()));
             }
         }
@@ -242,8 +243,8 @@ public class SearchCriteria<K> {
         return _joins.get(joinName).getT();
     }
 
-    public Pair<GroupBy<?, ?>, List<Object>> getGroupBy() {
-        return _groupBy == null ? null : new Pair<GroupBy<?, ?>, List<Object>>(_groupBy, _groupByValues);
+    public Pair<GroupBy<?, ?, ?>, List<Object>> getGroupBy() {
+        return _groupBy == null ? null : new Pair<GroupBy<?, ?, ?>, List<Object>>(_groupBy, _groupByValues);
     }
 
     public void setGroupByValues(Object... values) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
----------------------------------------------------------------------
diff --git a/framework/db/src/com/cloud/utils/db/SearchCriteria2.java b/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
index cccd220..1d9ed4b 100755
--- a/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
+++ b/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
@@ -23,11 +23,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.UUID;
 
-import net.sf.cglib.proxy.Factory;
-
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria.SelectType;
 
 public class SearchCriteria2<T, K> extends SearchBase<T, K> {
     final HashMap<String, Object[]> _params = new HashMap<String, Object[]>();
@@ -69,16 +66,6 @@ public class SearchCriteria2<T, K> extends SearchBase<T, K> {
         _specifiedAttrs.clear();
     }
 
-    private void constructCondition(String conditionName, String cond, Attribute attr, Op op) {
-        assert _entity != null : "SearchBuilder cannot be modified once it has been setup";
-        assert op == null || _specifiedAttrs.size() == 1 : "You didn't select the attribute.";
-        assert op != Op.SC : "Call join";
-
-        GenericSearchBuilder.Condition condition = new GenericSearchBuilder.Condition(conditionName, cond, attr, op);
-        _conditions.add(condition);
-        _specifiedAttrs.clear();
-    }
-
     private void setParameters(String conditionName, Object... params) {
         assert _conditions.contains(new Condition(conditionName)) : "Couldn't find " + conditionName;
         _params.put(conditionName, params);
@@ -91,8 +78,8 @@ public class SearchCriteria2<T, K> extends SearchBase<T, K> {
     }
 
     public List<K> list() {
-        done();
-        SearchCriteria sc1 = createSearchCriteria();
+        finalize();
+        SearchCriteria sc1 = create();
         if (isSelectAll()) {
             return (List<K>)_dao.search(sc1, null);
         } else {
@@ -108,43 +95,56 @@ public class SearchCriteria2<T, K> extends SearchBase<T, K> {
         return _entity;
     }
 
-    private SearchCriteria<K> createSearchCriteria() {
-        return new SearchCriteria<K>(_attrs, _conditions, _selects, _selectType, _resultType, _params);
+    public K find() {
+        assert isSelectAll() : "find doesn't support select search";
+        finalize();
+        SearchCriteria sc1 = create();
+        return (K)_dao.findOneBy(sc1);
     }
 
-    private void done() {
-        if (_entity != null) {
-            Factory factory = (Factory)_entity;
-            factory.setCallback(0, null);
-            _entity = null;
-        }
+    public Preset and(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " AND ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
 
-        if (_selects == null || _selects.size() == 0) {
-            _selectType = SelectType.Entity;
-            assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
-            return;
-        }
+    public Preset where(Object useless, Op op) {
+        return and(useless, op);
+    }
 
-        for (Select select : _selects) {
-            if (select.field == null) {
-                assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
-                _selectType = SelectType.Single;
-                return;
-            }
-            if (select.func != null) {
-                _selectType = SelectType.Result;
-                return;
-            }
-        }
+    public Preset left(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " ( ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
 
-        _selectType = SelectType.Fields;
+    public Preset op(Object useless, Op op) {
+        return left(useless, op);
     }
 
-    public <K> K find() {
-        assert isSelectAll() : "find doesn't support select search";
-        done();
-        SearchCriteria sc1 = createSearchCriteria();
-        return (K)_dao.findOneBy(sc1);
+    public Preset openParen(Object useless, Op op) {
+        return left(useless, op);
+    }
+
+    public Preset or(Object useless, Op op) {
+        Condition condition = constructCondition(UUID.randomUUID().toString(), " OR ", _specifiedAttrs.get(0), op);
+        return new Preset(this, condition);
+    }
+
+    public class Preset {
+        SearchCriteria2<T, K> builder;
+        Condition condition;
+
+        protected Preset(SearchCriteria2<T, K> builder, Condition condition) {
+            this.builder = builder;
+            this.condition = condition;
+        }
+
+        public SearchCriteria2<T, K> values(Object... params) {
+            if (condition.op.getParams() > 0 && condition.op.params != params.length) {
+                throw new RuntimeException("The # of parameters set " + params.length + " does not match # of parameters required by " + condition.op);
+            }
+            condition.setPresets(params);
+            return builder;
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
index ccb7f10..0cd231f 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
@@ -49,7 +49,7 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase<SyncQueueItemVO, Long>
         queueIdSearch = createSearchBuilder(Long.class);
         queueIdSearch.and("contentId", queueIdSearch.entity().getContentId(), Op.EQ);
         queueIdSearch.and("contentType", queueIdSearch.entity().getContentType(), Op.EQ);
-        queueIdSearch.selectField(queueIdSearch.entity().getId());
+        queueIdSearch.selectFields(queueIdSearch.entity().getId());
         queueIdSearch.done();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
index 2a4a06c..2ddb115 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
@@ -898,13 +898,13 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
 
         JoinJobSearch = _joinMapDao.createSearchBuilder(Long.class);
         JoinJobSearch.and(JoinJobSearch.entity().getJoinJobId(), Op.EQ, "joinJobId");
-        JoinJobSearch.selectField(JoinJobSearch.entity().getJobId());
+        JoinJobSearch.selectFields(JoinJobSearch.entity().getJobId());
         JoinJobSearch.done();
 
         JoinJobTimeSearch = _joinMapDao.createSearchBuilder(Long.class);
         JoinJobTimeSearch.and(JoinJobTimeSearch.entity().getNextWakeupTime(), Op.LT, "beginTime");
         JoinJobTimeSearch.and(JoinJobTimeSearch.entity().getExpiration(), Op.GT, "endTime");
-        JoinJobTimeSearch.selectField(JoinJobTimeSearch.entity().getJobId()).done();
+        JoinJobTimeSearch.selectFields(JoinJobTimeSearch.entity().getJobId()).done();
 
         JobIdsSearch = _jobDao.createSearchBuilder();
         JobIdsSearch.and(JobIdsSearch.entity().getId(), Op.IN, "ids").done();
@@ -913,13 +913,13 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
         QueueJobIdsSearch.and(QueueJobIdsSearch.entity().getContentId(), Op.IN, "contentIds").done();
 
         JoinJobIdsSearch = _joinMapDao.createSearchBuilder(Long.class);
-        JoinJobIdsSearch.selectField(JoinJobIdsSearch.entity().getJobId());
+        JoinJobIdsSearch.selectFields(JoinJobIdsSearch.entity().getJobId());
         JoinJobIdsSearch.and(JoinJobIdsSearch.entity().getJoinJobId(), Op.EQ, "joinJobId");
         JoinJobIdsSearch.and(JoinJobIdsSearch.entity().getJobId(), Op.NIN, "jobIds");
         JoinJobIdsSearch.done();
 
         ContentIdsSearch = _queueItemDao.createSearchBuilder(Long.class);
-        ContentIdsSearch.selectField(ContentIdsSearch.entity().getContentId()).done();
+        ContentIdsSearch.selectFields(ContentIdsSearch.entity().getContentId()).done();
 
         AsyncJobExecutionContext.init(this, _joinMapDao);
         OutcomeImpl.init(this);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a964cf54/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 96ffe35..415111d 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -459,7 +459,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         _serverId = _msServer.getId();
 
         UpHostsInPoolSearch = _storagePoolHostDao.createSearchBuilder(Long.class);
-        UpHostsInPoolSearch.selectField(UpHostsInPoolSearch.entity().getHostId());
+        UpHostsInPoolSearch.selectFields(UpHostsInPoolSearch.entity().getHostId());
         SearchBuilder<HostVO> hostSearch = _hostDao.createSearchBuilder();
         hostSearch.and("status", hostSearch.entity().getStatus(), Op.EQ);
         hostSearch.and("resourceState", hostSearch.entity().getResourceState(), Op.EQ);


Mime
View raw message