GeneralConfigDAO { public List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> getLikeGeneralConfig(String description, int required) { Session session = sessionFactory.openSession(); List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> generalConfigList = new ArrayList<com.wipro.ats.bdre.md.beans.table.GeneralConfig>(); try { session.beginTransaction(); if (required == 2) { Criteria getGeneralConfigCriteria = session.createCriteria(GeneralConfig.class).add(Restrictions.like(CONFIG_GROUP, "cluster%")).add(Restrictions.eq("description", description)).add(Restrictions.eq("enabled", true)); List<GeneralConfig> jpaGeneralConfigList = getGeneralConfigCriteria.list(); for (GeneralConfig jpaGeneralConfig : jpaGeneralConfigList) { com.wipro.ats.bdre.md.beans.table.GeneralConfig generalConfig = new com.wipro.ats.bdre.md.beans.table.GeneralConfig(); generalConfig.setCounter(jpaGeneralConfigList.size()); if (jpaGeneralConfig.getRequired()) generalConfig.setRequired(1); else generalConfig.setRequired(0); generalConfig.setConfigGroup(jpaGeneralConfig.getId().getConfigGroup()); generalConfig.setKey(jpaGeneralConfig.getId().getGcKey()); generalConfig.setValue(jpaGeneralConfig.getGcValue()); generalConfig.setDescription(jpaGeneralConfig.getDescription()); generalConfig.setDefaultVal(jpaGeneralConfig.getDefaultVal()); generalConfig.setEnabled(jpaGeneralConfig.getEnabled()); generalConfig.setType(jpaGeneralConfig.getType()); generalConfigList.add(generalConfig); } } else { boolean req = (required == 1) ? true : false; Criteria getGeneralConfigCriteria = session.createCriteria(GeneralConfig.class).add(Restrictions.like(CONFIG_GROUP, "cluster%")).add(Restrictions.eq("description", description)).add(Restrictions.eq("enabled", true)).add(Restrictions.eq("required", req)); List<GeneralConfig> jpaGeneralConfigList = getGeneralConfigCriteria.list(); for (GeneralConfig jpaGeneralConfig : jpaGeneralConfigList) { com.wipro.ats.bdre.md.beans.table.GeneralConfig generalConfig = new com.wipro.ats.bdre.md.beans.table.GeneralConfig(); generalConfig.setCounter(jpaGeneralConfigList.size()); if (jpaGeneralConfig.getRequired()) generalConfig.setRequired(1); else generalConfig.setRequired(0); generalConfig.setConfigGroup(jpaGeneralConfig.getId().getConfigGroup()); generalConfig.setKey(jpaGeneralConfig.getId().getGcKey()); generalConfig.setValue(jpaGeneralConfig.getGcValue()); generalConfig.setDescription(jpaGeneralConfig.getDescription()); generalConfig.setDefaultVal(jpaGeneralConfig.getDefaultVal()); generalConfig.setEnabled(jpaGeneralConfig.getEnabled()); generalConfig.setType(jpaGeneralConfig.getType()); generalConfigList.add(generalConfig); } } session.getTransaction().commit(); } catch (MetadataException e) { session.getTransaction().rollback(); LOGGER.error(e); } finally { session.close(); } return generalConfigList; }  List<GeneralConfig> list(Integer pageNum, Integer numResults); Integer totalRecordCount(); GeneralConfig get(GeneralConfigId generalConfigId); GeneralConfigId insert(GeneralConfig generalConfig); void update(GeneralConfig generalConfig); void delete(GeneralConfigId generalConfigId); void deleteByConfigGroup(String generalConfig); List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> getGeneralConfig(String configGroup, int required); List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> listGeneralConfig(String configGroup); List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> getLikeGeneralConfig(String description, int required); com.wipro.ats.bdre.md.beans.table.GeneralConfig getGenConfigProperty(String configGroup, String key); void insertCluster(ClusterInfo cluster); List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> getDistinctGenerelConfig(Integer pageNum, Integer numResults);  }
@Ignore @Test public void getLikeGeneralConfigTest() throws Exception { List<com.wipro.ats.bdre.md.beans.table.GeneralConfig> generalConfigList = generalConfigDAO.getLikeGeneralConfig("cluster", 1); LOGGER.info("generalConfig" + generalConfigList); }