Java Code Examples for org.springframework.jdbc.core.JdbcOperations

The following examples show how to use org.springframework.jdbc.core.JdbcOperations. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static int[] executeBatchUpdateWithNamedParameters(
		final ParsedSql parsedSql, final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {

	if (batchArgs.length == 0) {
		return new int[0];
	}

	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}
				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
Example 2
public static int[] executeBatchUpdateWithNamedParameters(
		final ParsedSql parsedSql, final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {

	if (batchArgs.length == 0) {
		return new int[0];
	}

	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {
				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}
				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
Example 3
public static int[] executeBatchUpdateWithNamedParameters(final ParsedSql parsedSql,
		final SqlParameterSource[] batchArgs, JdbcOperations jdbcOperations) {
	if (batchArgs.length <= 0) {
		return new int[] {0};
	}
	String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, batchArgs[0]);
	return jdbcOperations.batchUpdate(
			sqlToUse,
			new BatchPreparedStatementSetter() {

				@Override
				public void setValues(PreparedStatement ps, int i) throws SQLException {
					Object[] values = NamedParameterUtils.buildValueArray(parsedSql, batchArgs[i], null);
					int[] columnTypes = NamedParameterUtils.buildSqlTypeArray(parsedSql, batchArgs[i]);
					setStatementParameters(values, ps, columnTypes);
				}

				@Override
				public int getBatchSize() {
					return batchArgs.length;
				}
			});
}
 
Example 4
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
}
 
Example 5
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 6
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 7
@Autowired
public DefaultCalendarService(final EventDao eventDao,
                              final CalendarUserDao userDao,
                              final JdbcOperations jdbcOperations,
                              final PasswordEncoder passwordEncoder) {
    if (eventDao == null) {
        throw new IllegalArgumentException("eventDao cannot be null");
    }
    if (userDao == null) {
        throw new IllegalArgumentException("userDao cannot be null");
    }
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (passwordEncoder == null) {
        throw new IllegalArgumentException("passwordEncoder cannot be null");
    }
    this.eventDao = eventDao;
    this.userDao = userDao;
    this.jdbcOperations = jdbcOperations;
    this.passwordEncoder = passwordEncoder;
}
 
Example 8
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 9
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 10
Source Project: maven-framework-project   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 11
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 12
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 13
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 14
Source Project: maven-framework-project   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 15
Source Project: find   Source File: AbstractDeduplicateUsers.java    License: MIT License 5 votes vote down vote up
private void deleteDuplicateUsers(final JdbcOperations jdbcTemplate, final List<User> userEntities) {
    final String deleteSql = "DELETE FROM users WHERE user_id=?";
    jdbcTemplate.batchUpdate(deleteSql, new BatchPreparedStatementSetter() {
        @Override
        public void setValues(final PreparedStatement ps, final int i) throws SQLException {
            ps.setLong(1, userEntities.get(i + 1).getUserId());
        }

        @Override
        public int getBatchSize() {
            // Don't delete the first user
            return userEntities.size() - 1;
        }
    });
}
 
Example 16
Source Project: find   Source File: AbstractMigrateUsersToIncludeUsernames.java    License: MIT License 5 votes vote down vote up
private void updateUsers(final JdbcOperations jdbcTemplate, final List<DeprecatedUser> users) {
    final String sql = getUpdateUserSql();

    jdbcTemplate.batchUpdate(sql, new UsersBatchPreparedStatementSetter(
            users,
            (ps, i) -> getBatchParameters(ps, users.get(i))
    ));
}
 
Example 17
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 18
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 19
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 20
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 21
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 22
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 23
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 24
Source Project: maven-framework-project   Source File: JdbcCalendarUserDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 25
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 26
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 27
/**
 *
 * @param jdbcOperations
 *            the {@link JdbcOperations} used to perform the cleanup. Cannot be null.
 * @param tokenValidityInMs
 *            used to calculate when a token is expired. If the {@link #run()} method is invoked, tokens older than
 *            this amount of time will be deleted. Cannot be less than 1.
 */
public JdbcTokenRepositoryImplCleaner(JdbcOperations jdbcOperations, long tokenValidityInMs) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    if (tokenValidityInMs < 1) {
        throw new IllegalArgumentException("tokenValidityInMs must be greater than 0. Got " + tokenValidityInMs);
    }
    this.jdbcOperations = jdbcOperations;
    this.tokenValidityInMs = tokenValidityInMs;
}
 
Example 28
@Autowired
public JdbcCalendarUserDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 29
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}
 
Example 30
Source Project: Spring-Security-Third-Edition   Source File: JdbcEventDao.java    License: MIT License 5 votes vote down vote up
@Autowired
public JdbcEventDao(JdbcOperations jdbcOperations) {
    if (jdbcOperations == null) {
        throw new IllegalArgumentException("jdbcOperations cannot be null");
    }
    this.jdbcOperations = jdbcOperations;
}