@Test public void test_should_persist_create_usageType_to_DB() { final UsageTypeReq usageTypeReq = usageTypeRepository.create(getUsageTypeRequest()); assertThat(usageTypeReq.getUsageTypes().size()).isEqualTo(2); }
@SuppressWarnings("unchecked") public UsageTypeReq create(final UsageTypeReq usageTypeRequest) { final List<UsageType> usageTypes = usageTypeRequest.getUsageTypes(); final String usageTypeInsertQuery = usageTypeQueryBuilder.getUsageTypeInsertQuery(); final List<Map<String, Object>> usageTypeParamValues = new ArrayList<>(usageTypes.size()); for (final UsageType usageType : usageTypes) usageTypeParamValues.add(new MapSqlParameterSource("id", Long.valueOf(usageType.getCode())) .addValue("code", usageType.getCode()).addValue("name", usageType.getName()) .addValue("description", usageType.getDescription()).addValue("parent", usageType.getParent()) .addValue("active", usageType.getActive()) .addValue("createdby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantid", usageType.getTenantId()) .getValues()); try { namedParameterJdbcTemplate.batchUpdate(usageTypeInsertQuery, usageTypeParamValues.toArray(new Map[usageTypes.size()])); } catch (final Exception e) { logger.error("Error occured while persisting create usageType Request to db:" + e); } return usageTypeRequest; }
UsageTypeRepository { @SuppressWarnings("unchecked") public UsageTypeReq create(final UsageTypeReq usageTypeRequest) { final List<UsageType> usageTypes = usageTypeRequest.getUsageTypes(); final String usageTypeInsertQuery = usageTypeQueryBuilder.getUsageTypeInsertQuery(); final List<Map<String, Object>> usageTypeParamValues = new ArrayList<>(usageTypes.size()); for (final UsageType usageType : usageTypes) usageTypeParamValues.add(new MapSqlParameterSource("id", Long.valueOf(usageType.getCode())) .addValue("code", usageType.getCode()).addValue("name", usageType.getName()) .addValue("description", usageType.getDescription()).addValue("parent", usageType.getParent()) .addValue("active", usageType.getActive()) .addValue("createdby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantid", usageType.getTenantId()) .getValues()); try { namedParameterJdbcTemplate.batchUpdate(usageTypeInsertQuery, usageTypeParamValues.toArray(new Map[usageTypes.size()])); } catch (final Exception e) { logger.error("Error occured while persisting create usageType Request to db:" + e); } return usageTypeRequest; } }
UsageTypeRepository { @SuppressWarnings("unchecked") public UsageTypeReq create(final UsageTypeReq usageTypeRequest) { final List<UsageType> usageTypes = usageTypeRequest.getUsageTypes(); final String usageTypeInsertQuery = usageTypeQueryBuilder.getUsageTypeInsertQuery(); final List<Map<String, Object>> usageTypeParamValues = new ArrayList<>(usageTypes.size()); for (final UsageType usageType : usageTypes) usageTypeParamValues.add(new MapSqlParameterSource("id", Long.valueOf(usageType.getCode())) .addValue("code", usageType.getCode()).addValue("name", usageType.getName()) .addValue("description", usageType.getDescription()).addValue("parent", usageType.getParent()) .addValue("active", usageType.getActive()) .addValue("createdby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantid", usageType.getTenantId()) .getValues()); try { namedParameterJdbcTemplate.batchUpdate(usageTypeInsertQuery, usageTypeParamValues.toArray(new Map[usageTypes.size()])); } catch (final Exception e) { logger.error("Error occured while persisting create usageType Request to db:" + e); } return usageTypeRequest; }  }
UsageTypeRepository { @SuppressWarnings("unchecked") public UsageTypeReq create(final UsageTypeReq usageTypeRequest) { final List<UsageType> usageTypes = usageTypeRequest.getUsageTypes(); final String usageTypeInsertQuery = usageTypeQueryBuilder.getUsageTypeInsertQuery(); final List<Map<String, Object>> usageTypeParamValues = new ArrayList<>(usageTypes.size()); for (final UsageType usageType : usageTypes) usageTypeParamValues.add(new MapSqlParameterSource("id", Long.valueOf(usageType.getCode())) .addValue("code", usageType.getCode()).addValue("name", usageType.getName()) .addValue("description", usageType.getDescription()).addValue("parent", usageType.getParent()) .addValue("active", usageType.getActive()) .addValue("createdby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantid", usageType.getTenantId()) .getValues()); try { namedParameterJdbcTemplate.batchUpdate(usageTypeInsertQuery, usageTypeParamValues.toArray(new Map[usageTypes.size()])); } catch (final Exception e) { logger.error("Error occured while persisting create usageType Request to db:" + e); } return usageTypeRequest; }  List<UsageType> getUsageTypesByCriteria(final UsageTypeGetRequest usageTypeGetRequest); List<UsageType> pushCreateToQueue(final UsageTypeReq usageTypeRequest); @SuppressWarnings("unchecked") UsageTypeReq create(final UsageTypeReq usageTypeRequest); List<UsageType> pushUpdateToQueue(final UsageTypeReq usageTypeRequest); @SuppressWarnings("unchecked") UsageTypeReq update(final UsageTypeReq usageTypeRequest); }
UsageTypeRepository { @SuppressWarnings("unchecked") public UsageTypeReq create(final UsageTypeReq usageTypeRequest) { final List<UsageType> usageTypes = usageTypeRequest.getUsageTypes(); final String usageTypeInsertQuery = usageTypeQueryBuilder.getUsageTypeInsertQuery(); final List<Map<String, Object>> usageTypeParamValues = new ArrayList<>(usageTypes.size()); for (final UsageType usageType : usageTypes) usageTypeParamValues.add(new MapSqlParameterSource("id", Long.valueOf(usageType.getCode())) .addValue("code", usageType.getCode()).addValue("name", usageType.getName()) .addValue("description", usageType.getDescription()).addValue("parent", usageType.getParent()) .addValue("active", usageType.getActive()) .addValue("createdby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("createddate", new Date().getTime()) .addValue("lastmodifiedby", usageTypeRequest.getRequestInfo().getUserInfo().getId()) .addValue("lastmodifieddate", new Date().getTime()).addValue("tenantid", usageType.getTenantId()) .getValues()); try { namedParameterJdbcTemplate.batchUpdate(usageTypeInsertQuery, usageTypeParamValues.toArray(new Map[usageTypes.size()])); } catch (final Exception e) { logger.error("Error occured while persisting create usageType Request to db:" + e); } return usageTypeRequest; }  List<UsageType> getUsageTypesByCriteria(final UsageTypeGetRequest usageTypeGetRequest); List<UsageType> pushCreateToQueue(final UsageTypeReq usageTypeRequest); @SuppressWarnings("unchecked") UsageTypeReq create(final UsageTypeReq usageTypeRequest); List<UsageType> pushUpdateToQueue(final UsageTypeReq usageTypeRequest); @SuppressWarnings("unchecked") UsageTypeReq update(final UsageTypeReq usageTypeRequest); static final Logger logger; }