protected ProjectAccountDaoImpl() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("role", AllFieldsSearch.entity().getAccountRole(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("projectId", AllFieldsSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and(
        "projectAccountId", AllFieldsSearch.entity().getProjectAccountId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.done();

    AdminSearch = createSearchBuilder(Long.class);
    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.selectFields(ProjectAccountSearch.entity().getProjectAccountId());
    ProjectAccountSearch.and("accountId", ProjectAccountSearch.entity().getAccountId(), Op.EQ);
    ProjectAccountSearch.done();

    CountByRoleSearch = createSearchBuilder(Long.class);
    CountByRoleSearch.select(null, Func.COUNT, CountByRoleSearch.entity().getId());
    CountByRoleSearch.and("accountId", CountByRoleSearch.entity().getAccountId(), Op.EQ);
    CountByRoleSearch.and("role", CountByRoleSearch.entity().getAccountRole(), Op.EQ);
    CountByRoleSearch.done();
  }
  protected VpcServiceMapDaoImpl() {
    super();
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("service", AllFieldsSearch.entity().getService(), SearchCriteria.Op.EQ);
    AllFieldsSearch.and("provider", AllFieldsSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    AllFieldsSearch.done();

    MultipleServicesSearch = createSearchBuilder();
    MultipleServicesSearch.and(
        "vpcId", MultipleServicesSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    MultipleServicesSearch.and(
        "service", MultipleServicesSearch.entity().getService(), SearchCriteria.Op.IN);
    MultipleServicesSearch.and(
        "provider", MultipleServicesSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    MultipleServicesSearch.done();

    DistinctProvidersSearch = createSearchBuilder(String.class);
    DistinctProvidersSearch.and(
        "vpcId", DistinctProvidersSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
    DistinctProvidersSearch.and(
        "provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
    DistinctProvidersSearch.selectFields(DistinctProvidersSearch.entity().getProvider());
    DistinctProvidersSearch.done();
  }
  protected SecurityGroupVMMapDaoImpl() {
    ListByIpAndVmId = createSearchBuilder();
    ListByIpAndVmId.and(
        "ipAddress", ListByIpAndVmId.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
    ListByIpAndVmId.and(
        "instanceId", ListByIpAndVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByIpAndVmId.done();

    ListVmIdBySecurityGroup = createSearchBuilder(Long.class);
    ListVmIdBySecurityGroup.and(
        "securityGroupId",
        ListVmIdBySecurityGroup.entity().getSecurityGroupId(),
        SearchCriteria.Op.EQ);
    ListVmIdBySecurityGroup.selectFields(ListVmIdBySecurityGroup.entity().getInstanceId());
    ListVmIdBySecurityGroup.done();

    ListBySecurityGroup = createSearchBuilder();
    ListBySecurityGroup.and(
        "securityGroupId", ListBySecurityGroup.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
    ListBySecurityGroup.done();

    ListByIp = createSearchBuilder();
    ListByIp.and("ipAddress", ListByIp.entity().getGuestIpAddress(), SearchCriteria.Op.EQ);
    ListByIp.done();

    ListByVmId = createSearchBuilder();
    ListByVmId.and("instanceId", ListByVmId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByVmId.done();

    ListBySecurityGroupAndStates = createSearchBuilder();
    ListBySecurityGroupAndStates.and(
        "securityGroupId",
        ListBySecurityGroupAndStates.entity().getSecurityGroupId(),
        SearchCriteria.Op.EQ);
    ListBySecurityGroupAndStates.and(
        "states", ListBySecurityGroupAndStates.entity().getVmState(), SearchCriteria.Op.IN);
    ListBySecurityGroupAndStates.done();

    ListByVmIdGroupId = createSearchBuilder();
    ListByVmIdGroupId.and(
        "instanceId", ListByVmIdGroupId.entity().getInstanceId(), SearchCriteria.Op.EQ);
    ListByVmIdGroupId.and(
        "securityGroupId", ListByVmIdGroupId.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
    ListByVmIdGroupId.done();

    CountSGForVm = createSearchBuilder(Long.class);
    CountSGForVm.select(null, Func.COUNT, null);
    CountSGForVm.and("vmId", CountSGForVm.entity().getInstanceId(), SearchCriteria.Op.EQ);
    CountSGForVm.done();
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<IAMGroup> listIAMGroups(long accountId) {

    GenericSearchBuilder<IAMGroupAccountMapVO, Long> groupSB =
        _aclGroupAccountMapDao.createSearchBuilder(Long.class);
    groupSB.selectFields(groupSB.entity().getAclGroupId());
    groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);
    SearchCriteria<Long> groupSc = groupSB.create();
    groupSc.setParameters("account", accountId);

    List<Long> groupIds = _aclGroupAccountMapDao.customSearch(groupSc, null);

    SearchBuilder<IAMGroupVO> sb = _aclGroupDao.createSearchBuilder();
    sb.and("ids", sb.entity().getId(), Op.IN);
    SearchCriteria<IAMGroupVO> sc = sb.create();
    sc.setParameters("ids", groupIds.toArray(new Object[groupIds.size()]));
    @SuppressWarnings("rawtypes")
    List groups = _aclGroupDao.search(sc, null);
    return groups;
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<IAMPolicy> listIAMPolicies(long accountId) {

    // static policies of the account
    SearchBuilder<IAMGroupAccountMapVO> groupSB = _aclGroupAccountMapDao.createSearchBuilder();
    groupSB.and("account", groupSB.entity().getAccountId(), Op.EQ);

    GenericSearchBuilder<IAMGroupPolicyMapVO, Long> policySB =
        _aclGroupPolicyMapDao.createSearchBuilder(Long.class);
    policySB.selectFields(policySB.entity().getAclPolicyId());
    policySB.join(
        "accountgroupjoin",
        groupSB,
        groupSB.entity().getAclGroupId(),
        policySB.entity().getAclGroupId(),
        JoinType.INNER);
    policySB.done();
    SearchCriteria<Long> policySc = policySB.create();
    policySc.setJoinParameters("accountgroupjoin", "account", accountId);

    List<Long> policyIds = _aclGroupPolicyMapDao.customSearch(policySc, null);
    // add policies directly attached to the account
    List<IAMAccountPolicyMapVO> acctPolicies = _aclAccountPolicyMapDao.listByAccountId(accountId);
    for (IAMAccountPolicyMapVO p : acctPolicies) {
      policyIds.add(p.getIamPolicyId());
    }
    if (policyIds.size() == 0) {
      return new ArrayList<IAMPolicy>();
    }
    SearchBuilder<IAMPolicyVO> sb = _aclPolicyDao.createSearchBuilder();
    sb.and("ids", sb.entity().getId(), Op.IN);
    SearchCriteria<IAMPolicyVO> sc = sb.create();
    sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()]));
    @SuppressWarnings("rawtypes")
    List policies = _aclPolicyDao.customSearch(sc, null);

    return policies;
  }
  protected PhysicalNetworkTrafficTypeDaoImpl() {
    super();
    physicalNetworkSearch = createSearchBuilder();
    physicalNetworkSearch.and(
        "physicalNetworkId", physicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
    physicalNetworkSearch.and(
        "trafficType", physicalNetworkSearch.entity().getTrafficType(), Op.EQ);
    physicalNetworkSearch.done();

    kvmAllFieldsSearch = createSearchBuilder(String.class);
    kvmAllFieldsSearch.and(
        "physicalNetworkId", kvmAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    kvmAllFieldsSearch.and("trafficType", kvmAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    kvmAllFieldsSearch.selectFields(kvmAllFieldsSearch.entity().getKvmNetworkLabel());
    kvmAllFieldsSearch.done();

    hypervAllFieldsSearch = createSearchBuilder(String.class);
    hypervAllFieldsSearch.and(
        "physicalNetworkId", hypervAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    hypervAllFieldsSearch.and(
        "trafficType", hypervAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    hypervAllFieldsSearch.selectFields(hypervAllFieldsSearch.entity().getHypervNetworkLabel());
    hypervAllFieldsSearch.done();

    xenAllFieldsSearch = createSearchBuilder(String.class);
    xenAllFieldsSearch.and(
        "physicalNetworkId", xenAllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    xenAllFieldsSearch.and("trafficType", xenAllFieldsSearch.entity().getTrafficType(), Op.EQ);
    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.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.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.selectFields(ovmAllFieldsSearch.entity().getSimulatorNetworkLabel());
    ovmAllFieldsSearch.done();

    ovm3AllFieldsSearch = createSearchBuilder(String.class);
    ovm3AllFieldsSearch.and(
        "physicalNetworkId", ovm3AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    ovm3AllFieldsSearch.and("trafficType", ovm3AllFieldsSearch.entity().getTrafficType(), Op.EQ);
    ovm3AllFieldsSearch.selectFields(ovm3AllFieldsSearch.entity().getOvm3NetworkLabel());
    ovm3AllFieldsSearch.done();
  }
  @PostConstruct
  protected void init() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("trafficType", AllFieldsSearch.entity().getTrafficType(), Op.EQ);
    AllFieldsSearch.and("cidr", AllFieldsSearch.entity().getCidr(), Op.EQ);
    AllFieldsSearch.and("broadcastType", AllFieldsSearch.entity().getBroadcastDomainType(), Op.EQ);
    AllFieldsSearch.and("offering", AllFieldsSearch.entity().getNetworkOfferingId(), Op.EQ);
    AllFieldsSearch.and("datacenter", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
    AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
    AllFieldsSearch.and("related", AllFieldsSearch.entity().getRelated(), Op.EQ);
    AllFieldsSearch.and("guestType", AllFieldsSearch.entity().getGuestType(), Op.EQ);
    AllFieldsSearch.and("physicalNetwork", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);
    AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ);
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
    AllFieldsSearch.and("aclId", AllFieldsSearch.entity().getNetworkACLId(), Op.EQ);
    SearchBuilder<NetworkOfferingVO> join1 = _ntwkOffDao.createSearchBuilder();
    join1.and("isSystem", join1.entity().isSystemOnly(), Op.EQ);
    join1.and("isRedundant", join1.entity().getRedundantRouter(), Op.EQ);
    AllFieldsSearch.join(
        "offerings",
        join1,
        AllFieldsSearch.entity().getNetworkOfferingId(),
        join1.entity().getId(),
        JoinBuilder.JoinType.INNER);
    AllFieldsSearch.done();

    AccountSearch = createSearchBuilder();
    AccountSearch.and("offering", AccountSearch.entity().getNetworkOfferingId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join = _accountsDao.createSearchBuilder();
    join.and("account", join.entity().getAccountId(), Op.EQ);
    AccountSearch.join(
        "accounts",
        join,
        AccountSearch.entity().getId(),
        join.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), Op.EQ);
    AccountSearch.and("cidr", AccountSearch.entity().getCidr(), Op.EQ);
    AccountSearch.and("vpcId", AccountSearch.entity().getVpcId(), Op.EQ);
    AccountSearch.done();

    RelatedConfigSearch = createSearchBuilder();
    RelatedConfigSearch.and("offering", RelatedConfigSearch.entity().getNetworkOfferingId(), Op.EQ);
    RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder();
    join2.and("account", join2.entity().getAccountId(), Op.EQ);
    RelatedConfigSearch.join(
        "account",
        join2,
        join2.entity().getNetworkId(),
        RelatedConfigSearch.entity().getId(),
        JoinType.INNER);
    RelatedConfigSearch.done();

    AccountNetworkSearch = createSearchBuilder();
    AccountNetworkSearch.and("networkId", AccountNetworkSearch.entity().getId(), Op.EQ);
    SearchBuilder<NetworkAccountVO> mapJoin = _accountsDao.createSearchBuilder();
    mapJoin.and("accountId", mapJoin.entity().getAccountId(), Op.EQ);
    AccountNetworkSearch.join(
        "networkSearch",
        mapJoin,
        AccountNetworkSearch.entity().getId(),
        mapJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    AccountNetworkSearch.done();

    ZoneBroadcastUriSearch = createSearchBuilder();
    ZoneBroadcastUriSearch.and(
        "dataCenterId", ZoneBroadcastUriSearch.entity().getDataCenterId(), Op.EQ);
    ZoneBroadcastUriSearch.and(
        "broadcastUri", ZoneBroadcastUriSearch.entity().getBroadcastUri(), Op.EQ);
    ZoneBroadcastUriSearch.and("guestType", ZoneBroadcastUriSearch.entity().getGuestType(), Op.EQ);
    ZoneBroadcastUriSearch.done();

    CountByZoneAndURI = createSearchBuilder(Long.class);
    CountByZoneAndURI.select(null, Func.COUNT, null);
    CountByZoneAndURI.and("dataCenterId", CountByZoneAndURI.entity().getDataCenterId(), Op.EQ);
    CountByZoneAndURI.and("broadcastUri", CountByZoneAndURI.entity().getBroadcastUri(), Op.EQ);
    CountByZoneAndURI.and("guestType", CountByZoneAndURI.entity().getGuestType(), Op.EQ);

    CountByZoneAndURI.done();

    ZoneSecurityGroupSearch = createSearchBuilder();
    ZoneSecurityGroupSearch.and(
        "dataCenterId", ZoneSecurityGroupSearch.entity().getDataCenterId(), Op.EQ);
    SearchBuilder<NetworkServiceMapVO> offJoin = _ntwkSvcMap.createSearchBuilder();
    offJoin.and("service", offJoin.entity().getService(), Op.EQ);
    ZoneSecurityGroupSearch.join(
        "services",
        offJoin,
        ZoneSecurityGroupSearch.entity().getId(),
        offJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    ZoneSecurityGroupSearch.done();

    CountBy = createSearchBuilder(Integer.class);
    CountBy.select(null, Func.COUNT, CountBy.entity().getId());
    CountBy.and("offeringId", CountBy.entity().getNetworkOfferingId(), Op.EQ);
    CountBy.and("vpcId", CountBy.entity().getVpcId(), Op.EQ);
    CountBy.and("removed", CountBy.entity().getRemoved(), Op.NULL);
    SearchBuilder<NetworkOfferingVO> ntwkOffJoin = _ntwkOffDao.createSearchBuilder();
    ntwkOffJoin.and("isSystem", ntwkOffJoin.entity().isSystemOnly(), Op.EQ);
    CountBy.join(
        "offerings",
        ntwkOffJoin,
        CountBy.entity().getNetworkOfferingId(),
        ntwkOffJoin.entity().getId(),
        JoinBuilder.JoinType.INNER);
    CountBy.done();

    PhysicalNetworkSearch = createSearchBuilder();
    PhysicalNetworkSearch.and(
        "physicalNetworkId", PhysicalNetworkSearch.entity().getPhysicalNetworkId(), Op.EQ);
    PhysicalNetworkSearch.done();

    SecurityGroupSearch = createSearchBuilder();
    SearchBuilder<NetworkServiceMapVO> join3 = _ntwkSvcMap.createSearchBuilder();
    join3.and("service", join3.entity().getService(), Op.EQ);
    SecurityGroupSearch.join(
        "services",
        join3,
        SecurityGroupSearch.entity().getId(),
        join3.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SecurityGroupSearch.done();

    NetworksCount = createSearchBuilder(Integer.class);
    NetworksCount.select(null, Func.COUNT, NetworksCount.entity().getId());
    NetworksCount.and(
        "networkOfferingId", NetworksCount.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
    NetworksCount.done();

    NetworksRegularUserCanCreateSearch = createSearchBuilder(Long.class);
    NetworksRegularUserCanCreateSearch.and(
        "aclType", NetworksRegularUserCanCreateSearch.entity().getAclType(), Op.EQ);
    NetworksRegularUserCanCreateSearch.select(
        null, Func.COUNT, NetworksRegularUserCanCreateSearch.entity().getId());
    SearchBuilder<NetworkAccountVO> join4 = _accountsDao.createSearchBuilder();
    join4.and("account", join4.entity().getAccountId(), Op.EQ);
    join4.and("isOwner", join4.entity().isOwner(), Op.EQ);
    NetworksRegularUserCanCreateSearch.join(
        "accounts",
        join4,
        NetworksRegularUserCanCreateSearch.entity().getId(),
        join4.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SearchBuilder<NetworkOfferingVO> join5 = _ntwkOffDao.createSearchBuilder();
    join5.and("specifyVlan", join5.entity().getSpecifyVlan(), Op.EQ);
    NetworksRegularUserCanCreateSearch.join(
        "ntwkOff",
        join5,
        NetworksRegularUserCanCreateSearch.entity().getNetworkOfferingId(),
        join5.entity().getId(),
        JoinBuilder.JoinType.INNER);
    NetworksRegularUserCanCreateSearch.done();

    _tgMacAddress = _tgs.get("macAddress");

    SourceNATSearch = createSearchBuilder();
    SourceNATSearch.and("account", SourceNATSearch.entity().getAccountId(), Op.EQ);
    SourceNATSearch.and("datacenter", SourceNATSearch.entity().getDataCenterId(), Op.EQ);
    SourceNATSearch.and("guestType", SourceNATSearch.entity().getGuestType(), Op.EQ);
    SearchBuilder<NetworkServiceMapVO> join6 = _ntwkSvcMap.createSearchBuilder();
    join6.and("service", join6.entity().getService(), Op.EQ);
    SourceNATSearch.join(
        "services",
        join6,
        SourceNATSearch.entity().getId(),
        join6.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    SourceNATSearch.done();

    VpcNetworksCount = createSearchBuilder(Long.class);
    VpcNetworksCount.and("vpcId", VpcNetworksCount.entity().getVpcId(), Op.EQ);
    VpcNetworksCount.select(null, Func.COUNT, VpcNetworksCount.entity().getId());
    SearchBuilder<NetworkOfferingVO> join9 = _ntwkOffDao.createSearchBuilder();
    join9.and("isSystem", join9.entity().isSystemOnly(), Op.EQ);
    VpcNetworksCount.join(
        "offerings",
        join9,
        VpcNetworksCount.entity().getNetworkOfferingId(),
        join9.entity().getId(),
        JoinBuilder.JoinType.INNER);
    VpcNetworksCount.done();

    OfferingAccountNetworkSearch = createSearchBuilder();
    OfferingAccountNetworkSearch.select(
        null, Func.DISTINCT, OfferingAccountNetworkSearch.entity().getId());
    SearchBuilder<NetworkOfferingVO> ntwkOfferingJoin = _ntwkOffDao.createSearchBuilder();
    ntwkOfferingJoin.and("isSystem", ntwkOfferingJoin.entity().isSystemOnly(), Op.EQ);
    OfferingAccountNetworkSearch.join(
        "ntwkOfferingSearch",
        ntwkOfferingJoin,
        OfferingAccountNetworkSearch.entity().getNetworkOfferingId(),
        ntwkOfferingJoin.entity().getId(),
        JoinBuilder.JoinType.LEFT);
    SearchBuilder<NetworkAccountVO> ntwkAccountJoin = _accountsDao.createSearchBuilder();
    ntwkAccountJoin.and("accountId", ntwkAccountJoin.entity().getAccountId(), Op.EQ);
    OfferingAccountNetworkSearch.join(
        "ntwkAccountSearch",
        ntwkAccountJoin,
        OfferingAccountNetworkSearch.entity().getId(),
        ntwkAccountJoin.entity().getNetworkId(),
        JoinBuilder.JoinType.INNER);
    OfferingAccountNetworkSearch.and(
        "zoneId", OfferingAccountNetworkSearch.entity().getDataCenterId(), Op.EQ);
    OfferingAccountNetworkSearch.and(
        "type", OfferingAccountNetworkSearch.entity().getGuestType(), Op.EQ);
    OfferingAccountNetworkSearch.done();

    GarbageCollectedSearch = createSearchBuilder(Long.class);
    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);
    join7.and("check", join7.entity().isCheckForGc(), Op.EQ);
    GarbageCollectedSearch.join(
        "ntwkOpGC",
        join7,
        GarbageCollectedSearch.entity().getId(),
        join7.entity().getId(),
        JoinBuilder.JoinType.INNER);
    SearchBuilder<NetworkOfferingVO> join8 = _ntwkOffDao.createSearchBuilder();
    join8.and("isPersistent", join8.entity().getIsPersistent(), Op.EQ);
    GarbageCollectedSearch.join(
        "ntwkOffGC",
        join8,
        GarbageCollectedSearch.entity().getNetworkOfferingId(),
        join8.entity().getId(),
        JoinBuilder.JoinType.INNER);
    GarbageCollectedSearch.done();
  }