org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider Java Examples
The following examples show how to use
org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider.
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: DatabaseItemWriterDemo.java From SpringAll with MIT License | 6 votes |
private ItemWriter<TestData> dataSourceItemWriter() { // ItemWriter的实现类之一,mysql数据库数据写入使用JdbcBatchItemWriter, // 其他实现:MongoItemWriter,Neo4jItemWriter等 JdbcBatchItemWriter<TestData> writer = new JdbcBatchItemWriter<>(); writer.setDataSource(dataSource); // 设置数据源 String sql = "insert into TEST(id,field1,field2,field3) values (:id,:field1,:field2,:field3)"; writer.setSql(sql); // 设置插入sql脚本 // 映射TestData对象属性到占位符中的属性 BeanPropertyItemSqlParameterSourceProvider<TestData> provider = new BeanPropertyItemSqlParameterSourceProvider<>(); writer.setItemSqlParameterSourceProvider(provider); writer.afterPropertiesSet(); // 设置一些额外属性 return writer; }
Example #2
Source File: BatchConfiguration.java From batch-processing-large-datasets-spring with MIT License | 5 votes |
@Bean public JdbcBatchItemWriter<Voltage> writer(final DataSource dataSource) { return new JdbcBatchItemWriterBuilder<Voltage>() .itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()) .sql("INSERT INTO voltage (volt, time) VALUES (:volt, :time)") .dataSource(dataSource) .build(); }
Example #3
Source File: PeopleWriter.java From spring-cloud with Apache License 2.0 | 5 votes |
@Bean @Qualifier("jdbcBatchItemWriter") public JdbcBatchItemWriter<People> jdbcBatchItemWriter() { JdbcBatchItemWriter<People> writer = new JdbcBatchItemWriter<>(); writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()); writer.setSql("insert into people (person_id, first_name, last_name) VALUES (uuid(), :firstName, :lastName)"); writer.setDataSource(w_dataSource); return writer; }
Example #4
Source File: BatchConfiguration.java From Software-Architecture-with-Spring-5.0 with MIT License | 5 votes |
@Bean(name = DATA_WRITER) public JdbcBatchItemWriter<JavaChampion> writer(DataSource dataSource) throws Exception { JdbcBatchItemWriter<JavaChampion> jdbcBatchItemWriter = new JdbcBatchItemWriter<JavaChampion>(); jdbcBatchItemWriter.setAssertUpdates(true); jdbcBatchItemWriter.setDataSource(dataSource); jdbcBatchItemWriter.setSql( " INSERT INTO java_champion( first_name, last_name, country, year )" + " VALUES ( :firstName , :lastName, :country, :year ) "); jdbcBatchItemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()); return jdbcBatchItemWriter; }
Example #5
Source File: BatchConfig.java From Software-Architecture-with-Spring-5.0 with MIT License | 5 votes |
@Bean public JdbcBatchItemWriter<PayrollTo> writer(DataSource dataSource) { return new JdbcBatchItemWriterBuilder<PayrollTo>() .itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()) .sql("INSERT INTO PAYROLL (PERSON_IDENTIFICATION, CURRENCY, TX_AMMOUNT, ACCOUNT_TYPE, ACCOUNT_ID, TX_DESCRIPTION, FIRST_LAST_NAME) VALUES (:identification,:currency,:ammount,:accountType, :accountNumber, :description, :firstLastName)") .dataSource(dataSource) .build(); }
Example #6
Source File: JobConfiguration.java From CogStack-Pipeline with Apache License 2.0 | 5 votes |
@Bean @StepScope @Qualifier("simpleJdbcItemWriter") @Profile("jdbc_out") public ItemWriter<Document> simpleJdbcItemWriter( @Qualifier("targetDataSource") DataSource jdbcDocumentTarget) { JdbcBatchItemWriter<Document> writer = new JdbcBatchItemWriter<>(); writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()); writer.setSql(env.getRequiredProperty("target.Sql")); writer.setDataSource(jdbcDocumentTarget); return writer; }
Example #7
Source File: BatchConfiguration.java From building-microservices with Apache License 2.0 | 5 votes |
@Bean JdbcBatchItemWriter<Person> jdbcBatchItemWriter(DataSource h2) { JdbcBatchItemWriter<Person> w = new JdbcBatchItemWriter<>(); w.setDataSource(h2); w.setSql("insert into PEOPLE( first, last, email) values ( :first, :last, :email )"); w.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()); return w; }
Example #8
Source File: FlatFileToDbNoSkipJobConfiguration.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Bean public JdbcBatchItemWriter<Item> jdbcBatchItemWriter() { JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>(); itemWriter.setSql( "INSERT INTO ITEM (ID, DESCRIPTION, FIRST_ACTION, SECOND_ACTION) VALUES (:id,:description,:firstAction,:secondAction)"); itemWriter.setDataSource(dataSource); itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>()); return itemWriter; }
Example #9
Source File: FlatFileToDbSkipReaderTransactionalJobConfiguration.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Bean public JdbcBatchItemWriter<Item> jdbcBatchItemWriter() { JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>(); itemWriter.setSql("INSERT INTO ITEM (ID, DESCRIPTION) VALUES (:id,:description)"); itemWriter.setDataSource(dataSource); itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>()); return itemWriter; }
Example #10
Source File: FlatFileToDbSkipProcessorNonTransactionalJobConfiguration.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Bean public JdbcBatchItemWriter<Item> jdbcBatchItemWriter() { JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>(); itemWriter.setSql("INSERT INTO ITEM (ID, DESCRIPTION) VALUES (:id,:description)"); itemWriter.setDataSource(dataSource); itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>()); return itemWriter; }
Example #11
Source File: FlatFileToDbSkipJobConfiguration.java From spring-boot-starter-batch-web with Apache License 2.0 | 5 votes |
@Bean public JdbcBatchItemWriter<Item> jdbcBatchItemWriter() { JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>(); itemWriter.setSql("INSERT INTO ITEM (ID, DESCRIPTION) VALUES (:id,:description)"); itemWriter.setDataSource(dataSource); itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>()); return itemWriter; }
Example #12
Source File: ConferenceItemWriter.java From spring4-sandbox with Apache License 2.0 | 4 votes |
public ConferenceItemWriter(DataSource ds) { super(); setDataSource(ds); setSql("update conference set name=:name where id=:id"); setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Conference>() ); }