@SuppressWarnings("unchecked") @Override public List<Country> getCountries(Language language) throws ServiceException { List<Country> countries = null; try { // CacheUtils cacheUtils = CacheUtils.getInstance(); countries = (List<Country>) cache.getFromCache("COUNTRIES_" + language.getCode()); if (countries == null) { countries = countryDao.listByLanguage(language); // set names for (Country country : countries) { CountryDescription description = country.getDescriptions().get(0); country.setName(description.getName()); } cache.putInCache(countries, "COUNTRIES_" + language.getCode()); } } catch (Exception e) { LOGGER.error("getCountries()", e); } return countries; }
public Country getByCode(String code) throws ServiceException { return countryDao.getByField(Country_.isoCode, code); }