@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void testCreateIds() { final List<Long> createdIds = daoHelper.createIds(JUNIT_SEQUENCE_NAME, TEMP_LIST_CAPACITY.intValue()); assertEquals("Unexpected number of retrieved IDs.", TEMP_LIST_CAPACITY.intValue(), createdIds.size()); }
@Transactional(propagation = Propagation.MANDATORY) public List<Long> createIds(final String sequenceName, final int count) { Assert.isTrue(StringUtils.isNotBlank(sequenceName)); if (count == 0) { return Collections.emptyList(); } final List<String> rows = LongStream.range(0L, count).mapToObj(l -> "(" + l + ") ") .collect(Collectors.toList()); String query = getQueryFilledWithTempTable(createIdsQuery, rows); final MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(HelperParameters.SEQUENCE_NAME.name(), sequenceName.trim()); return getNamedParameterJdbcTemplate().queryForList(query, params, Long.class); }
DaoHelper extends NamedParameterJdbcDaoSupport { @Transactional(propagation = Propagation.MANDATORY) public List<Long> createIds(final String sequenceName, final int count) { Assert.isTrue(StringUtils.isNotBlank(sequenceName)); if (count == 0) { return Collections.emptyList(); } final List<String> rows = LongStream.range(0L, count).mapToObj(l -> "(" + l + ") ") .collect(Collectors.toList()); String query = getQueryFilledWithTempTable(createIdsQuery, rows); final MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(HelperParameters.SEQUENCE_NAME.name(), sequenceName.trim()); return getNamedParameterJdbcTemplate().queryForList(query, params, Long.class); } }
DaoHelper extends NamedParameterJdbcDaoSupport { @Transactional(propagation = Propagation.MANDATORY) public List<Long> createIds(final String sequenceName, final int count) { Assert.isTrue(StringUtils.isNotBlank(sequenceName)); if (count == 0) { return Collections.emptyList(); } final List<String> rows = LongStream.range(0L, count).mapToObj(l -> "(" + l + ") ") .collect(Collectors.toList()); String query = getQueryFilledWithTempTable(createIdsQuery, rows); final MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(HelperParameters.SEQUENCE_NAME.name(), sequenceName.trim()); return getNamedParameterJdbcTemplate().queryForList(query, params, Long.class); }  }
DaoHelper extends NamedParameterJdbcDaoSupport { @Transactional(propagation = Propagation.MANDATORY) public List<Long> createIds(final String sequenceName, final int count) { Assert.isTrue(StringUtils.isNotBlank(sequenceName)); if (count == 0) { return Collections.emptyList(); } final List<String> rows = LongStream.range(0L, count).mapToObj(l -> "(" + l + ") ") .collect(Collectors.toList()); String query = getQueryFilledWithTempTable(createIdsQuery, rows); final MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(HelperParameters.SEQUENCE_NAME.name(), sequenceName.trim()); return getNamedParameterJdbcTemplate().queryForList(query, params, Long.class); }  @Required void setCreateIdQuery(final String createIdQuery); @Transactional(propagation = Propagation.MANDATORY) Long createId(final String sequenceName); static String getQueryFilledWithIdArray(String queryTemplate, Collection<?> ids); static String getQueryFilledWithStringArray(String queryTemplate, Collection<String> ids); static String getQueryFilledWithTempTable(String queryTemplate, Collection<?> ids); @Required void setCreateIdsQuery(final String createIdsQuery); @Transactional(propagation = Propagation.MANDATORY) List<Long> createIds(final String sequenceName, final int count); String escapeUnderscore(String query); static String replaceInClause(String query, int paramsCount); }
DaoHelper extends NamedParameterJdbcDaoSupport { @Transactional(propagation = Propagation.MANDATORY) public List<Long> createIds(final String sequenceName, final int count) { Assert.isTrue(StringUtils.isNotBlank(sequenceName)); if (count == 0) { return Collections.emptyList(); } final List<String> rows = LongStream.range(0L, count).mapToObj(l -> "(" + l + ") ") .collect(Collectors.toList()); String query = getQueryFilledWithTempTable(createIdsQuery, rows); final MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue(HelperParameters.SEQUENCE_NAME.name(), sequenceName.trim()); return getNamedParameterJdbcTemplate().queryForList(query, params, Long.class); }  @Required void setCreateIdQuery(final String createIdQuery); @Transactional(propagation = Propagation.MANDATORY) Long createId(final String sequenceName); static String getQueryFilledWithIdArray(String queryTemplate, Collection<?> ids); static String getQueryFilledWithStringArray(String queryTemplate, Collection<String> ids); static String getQueryFilledWithTempTable(String queryTemplate, Collection<?> ids); @Required void setCreateIdsQuery(final String createIdsQuery); @Transactional(propagation = Propagation.MANDATORY) List<Long> createIds(final String sequenceName, final int count); String escapeUnderscore(String query); static String replaceInClause(String query, int paramsCount); static final String QUOTE; }