@Override
@Transactional
	public List<Merchant> getMerchant(String id) throws Exception {

		List<Merchant> merchants = new ArrayList<Merchant>();
		try {
			System.out.println("id" + id);
			if (id.startsWith("C_")) {

				System.out.println("for category.....");
				String cId = id.replace("C_", "");
				System.out.println(cId);
				int categoryId = Integer.parseInt(cId);

				String query = "select DISTINCT(assoc.oMerchant.iMerchantId) from MerchantSubCategoryAssoc assoc, SubCategory sb, Category cb where sb.iSubCategoryId=assoc.oSubCategory.iSubCategoryId and assoc.deletedFlag='N' and sb.oParentCategory.iCategoryId=:id";
				Query merchantCount = sessionFactory.getCurrentSession()
						.createQuery(query);
				merchantCount.setParameter("id", categoryId);
				List<Integer> list = merchantCount.list();
				Iterator<Integer> iterator = list.iterator();
				while (iterator.hasNext()) {
					Integer merchantId = iterator.next();

					Merchant merchant = (Merchant) sessionFactory
							.getCurrentSession().load(Merchant.class,
									merchantId);
					System.out.println("merchant----->" + merchant);
					merchants.add(merchant);
				}
			} else {

				System.out.println("for sub Category");
				String cId = id.replace("S_", "");
				System.out.println(cId);
				String query2 = "select DISTINCT(assoc.oMerchant.iMerchantId) from MerchantSubCategoryAssoc assoc where assoc.deletedFlag='N' and assoc.oSubCategory.iSubCategoryId=:id";
				Query subMerchantCount = sessionFactory.getCurrentSession()
						.createQuery(query2);
				System.out.println("sub id---------" + cId);
				subMerchantCount.setString("id", cId);
				List<Integer> sMerchantCount = subMerchantCount.list();
				System.out.println("sub category merchant----"
						+ sMerchantCount.size());
				Iterator<Integer> iterator = sMerchantCount.iterator();
				while (iterator.hasNext()) {
					Integer merchantId = iterator.next();

					Merchant merchant = (Merchant) sessionFactory
							.getCurrentSession().load(Merchant.class,
									merchantId);
					System.out.println("merchant----->" + merchant);
					merchants.add(merchant);
				}
			}
		} catch (Exception exception) {
			exception.printStackTrace();
			throw exception;
		}
		return merchants;
	}