public Merchant getDetails(String merchantName) { String baseKey = "merchant." + merchantName; Merchant merchant = new Merchant(); // or use template directly merchant.setName(template.opsForValue().get(baseKey + ".name")); merchant.setPhoneNumber(template.opsForValue().get(baseKey + ".phone")); merchant.setEmail(template.opsForValue().get(baseKey + ".email")); merchant .getWalletMerchantId() .put( Wallets.PAYTM, template.opsForValue().get(baseKey + Wallets.PAYTM.getRedisMerchantIdKey())); merchant .getWalletMerchantId() .put( Wallets.PAYUMONEY, template.opsForValue().get(baseKey + Wallets.PAYUMONEY.getRedisMerchantIdKey())); merchant .getWalletMerchantId() .put( Wallets.CITRUS, template.opsForValue().get(baseKey + Wallets.CITRUS.getRedisMerchantIdKey())); return merchant; }