org.springframework.jdbc.core.JdbcOperations Java Examples

The following examples show how to use org.springframework.jdbc.core.JdbcOperations. 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
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@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 #2
Source File: NamedParameterBatchUpdateUtils.java    From java-technology-stack with MIT License 6 votes vote down vote up
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
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@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 #4
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@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 #5
Source File: DefaultCalendarService.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@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
Source File: NamedParameterBatchUpdateUtils.java    From spring-analysis-note with MIT License 6 votes vote down vote up
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 #7
Source File: NamedParameterBatchUpdateUtils.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: JdbcBenchmark.java    From spring-data-dev-tools with Apache License 2.0 5 votes vote down vote up
@Setup
@SuppressWarnings("unchecked")
public void setUp() {

	JdbcFixture fixture = new JdbcFixture(profile);

	this.bookMapper = fixture.getBookMapper();

	ConfigurableApplicationContext context = fixture.getContext();

	this.operations = context.getBean(JdbcOperations.class);
	this.repository = context.getBean(JdbcBookRepository.class);

	JdbcConverter converter = context.getBean(JdbcConverter.class);
	JdbcMappingContext mappingContext = context.getBean(JdbcMappingContext.class);

	RelationalPersistentEntity<Book> requiredPersistentEntity = (RelationalPersistentEntity<Book>) mappingContext
			.getRequiredPersistentEntity(Book.class);

	this.bookEntityMapper = new EntityRowMapper<Book>(requiredPersistentEntity, converter);

	// ResultSet mock

	this.columns = new TreeSet<>();
	columns.add("id");
	columns.add("title");
	columns.add("pages");

	this.values = new HashMap<>();
	values.put("id", 1L);
	values.put("title", "title0");
	values.put("pages", 42L);
}
 
Example #9
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 File: JdbcTemplateCrudDSL.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
public JdbcTemplateCrud<T, K> to(JdbcOperations jdbcOperations, final String table) {
    final JdbcMapperFactory factory = JdbcMapperFactory.newInstance(jdbcTemplateMapperFactory);

    Crud<T, K> crud =
        jdbcOperations.execute(new ConnectionCallback<Crud<T, K>>() {
            @Override
            public Crud<T, K> doInConnection(Connection connection) throws SQLException, DataAccessException {
                return factory.<T, K>crud(target, keyTarget).table(connection, table);
            }
        });

    return new JdbcTemplateCrud<T, K>(jdbcOperations, crud);
}
 
Example #11
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #12
Source File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #13
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #14
Source File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #15
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #16
Source File: JdbcCalendarUserDao.java    From maven-framework-project with 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 #17
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #18
Source File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #19
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #21
Source File: JdbcTokenRepositoryImplCleaner.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 *
 * @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 #22
Source File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #23
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #25
Source File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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 #26
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 #28
Source File: JdbcCalendarUserDao.java    From maven-framework-project with 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 #29
Source File: JdbcEventDao.java    From Spring-Security-Third-Edition with 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 File: JdbcCalendarUserDao.java    From Spring-Security-Third-Edition with 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;
}