org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations Java Examples
The following examples show how to use
org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations.
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: JdbcSinkIntegrationTests.java From spring-cloud-stream-app-starters with Apache License 2.0 | 6 votes |
@Test public void testInsertion() { NamedParameterJdbcOperations namedParameterJdbcOperations = new NamedParameterJdbcTemplate(jdbcOperations); Map<String, Object> mapA = new HashMap<>(); mapA.put("a", "hello1"); mapA.put("b", 42); Map<String, Object> mapB = new HashMap<>(); mapB.put("a", "hello2"); mapB.put("b", null); Map<String, Object> mapC = new HashMap<>(); mapC.put("a", "hello3"); channels.input().send(MessageBuilder.withPayload(mapA).build()); channels.input().send(MessageBuilder.withPayload(mapB).build()); channels.input().send(MessageBuilder.withPayload(mapC).build()); Assert.assertThat(namedParameterJdbcOperations.queryForObject( "select count(*) from messages where a = :a and b = :b", mapA, Integer.class), is(1)); Assert.assertThat(namedParameterJdbcOperations.queryForObject( "select count(*) from messages where a = :a and b IS NULL", mapB, Integer.class), is(1)); Assert.assertThat(namedParameterJdbcOperations.queryForObject( "select count(*) from messages where a = :a and b IS NULL", mapC, Integer.class), is(1)); }
Example #2
Source File: JdbcTemplateAutoConfiguration.java From sqlhelper with GNU Lesser General Public License v3.0 | 5 votes |
@Bean @Primary @ConditionalOnSingleCandidate(JdbcTemplate.class) @ConditionalOnMissingBean(NamedParameterJdbcOperations.class) public NamedParameterJdbcTemplate namedParameterJdbcTemplate(JdbcTemplate jdbcTemplate) { return new NamedParameterJdbcTemplate(jdbcTemplate); }
Example #3
Source File: QuerydslJdbcRepositoryFactoryBean.java From infobip-spring-data-querydsl with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() { Assert.state(this.mappingContext != null, "MappingContext is required and must not be null!"); Assert.state(this.converter != null, "RelationalConverter is required and must not be null!"); if (this.operations == null) { Assert.state(beanFactory != null, "If no JdbcOperations are set a BeanFactory must be available."); this.operations = beanFactory.getBean(NamedParameterJdbcOperations.class); } if (this.dataAccessStrategy == null) { Assert.state(beanFactory != null, "If no DataAccessStrategy is set a BeanFactory must be available."); this.dataAccessStrategy = this.beanFactory.getBeanProvider(DataAccessStrategy.class) // .getIfAvailable(() -> { SqlGeneratorSource sqlGeneratorSource = new SqlGeneratorSource( this.mappingContext, this.converter, this.dialect); return new DefaultDataAccessStrategy(sqlGeneratorSource, this.mappingContext, this.converter, this.operations); }); } if (this.queryMappingConfiguration == null) { this.queryMappingConfiguration = QueryMappingConfiguration.EMPTY; } if (beanFactory != null) { entityCallbacks = EntityCallbacks.create(beanFactory); } super.afterPropertiesSet(); }
Example #4
Source File: QuerydslJdbcRepositoryFactory.java From infobip-spring-data-querydsl with Apache License 2.0 | 5 votes |
public QuerydslJdbcRepositoryFactory(DataAccessStrategy dataAccessStrategy, RelationalMappingContext context, JdbcConverter converter, Dialect dialect, ApplicationEventPublisher publisher, NamedParameterJdbcOperations operations, SQLQueryFactory sqlQueryFactory) { super(dataAccessStrategy, context, converter, dialect, publisher, operations); this.publisher = publisher; this.context = context; this.converter = converter; this.accessStrategy = dataAccessStrategy; this.sqlQueryFactory = sqlQueryFactory; }
Example #5
Source File: SimpleJdbcTemplateTests.java From effectivejava with Apache License 2.0 | 5 votes |
@Before public void setup() { this.operations = mock(JdbcOperations.class); this.namedParameterOperations = mock(NamedParameterJdbcOperations.class); this.template = new SimpleJdbcTemplate(operations); this.namedParameterTemplate = new SimpleJdbcTemplate(namedParameterOperations); }
Example #6
Source File: LendingDatabaseConfig.java From library with MIT License | 4 votes |
@Bean NamedParameterJdbcOperations operations() { return new NamedParameterJdbcTemplate(dataSource()); }
Example #7
Source File: CatalogueDatabaseConfig.java From library with MIT License | 4 votes |
@Bean NamedParameterJdbcOperations operations() { return new NamedParameterJdbcTemplate(dataSource()); }
Example #8
Source File: QuerydslJdbcRepositoryFactoryBean.java From infobip-spring-data-querydsl with Apache License 2.0 | 4 votes |
public void setJdbcOperations(NamedParameterJdbcOperations operations) { this.operations = operations; }
Example #9
Source File: JdbcJobRepository.java From piper with Apache License 2.0 | 4 votes |
public void setJdbcOperations (NamedParameterJdbcOperations aJdbcOperations) { jdbc = aJdbcOperations; }
Example #10
Source File: JdbcTaskExecutionRepository.java From piper with Apache License 2.0 | 4 votes |
public void setJdbcOperations (NamedParameterJdbcOperations aJdbcOperations) { jdbc = aJdbcOperations; }
Example #11
Source File: DefaultJdbcListFactory.java From MaxKey with Apache License 2.0 | 4 votes |
/** * @param jdbcTemplate the jdbc template to use */ public DefaultJdbcListFactory(NamedParameterJdbcOperations jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; }
Example #12
Source File: SimpleJdbcTemplate.java From effectivejava with Apache License 2.0 | 4 votes |
/** * Expose the Spring NamedParameterJdbcTemplate to allow invocation of * less commonly used methods. */ @Override public NamedParameterJdbcOperations getNamedParameterJdbcOperations() { return this.namedParameterJdbcOperations; }
Example #13
Source File: JdbcConfig.java From platform with Apache License 2.0 | 4 votes |
@Bean public NamedParameterJdbcOperations namedParameterJdbcOperations(DataSource dataSource) { return new NamedParameterJdbcTemplate(dataSource); }
Example #14
Source File: SimpleJdbcTemplate.java From effectivejava with Apache License 2.0 | 2 votes |
/** * Create a new SimpleJdbcTemplate for the given Spring NamedParameterJdbcTemplate. * @param namedParameterJdbcTemplate the Spring NamedParameterJdbcTemplate to wrap */ public SimpleJdbcTemplate(NamedParameterJdbcOperations namedParameterJdbcTemplate) { this.namedParameterJdbcOperations = namedParameterJdbcTemplate; }
Example #15
Source File: SimpleJdbcOperations.java From effectivejava with Apache License 2.0 | 2 votes |
/** * Expose the Spring NamedParameterJdbcTemplate to allow invocation of less * commonly used methods. */ NamedParameterJdbcOperations getNamedParameterJdbcOperations();