writers

Spring Batch - write to 2 tables at once

蹲街弑〆低调 提交于 2020-04-30 09:19:28
问题 I have a Person object that has a list of addresses. My Spring Batch app converts Person JSON recors into Person POJOs and writes them to a database. Ordinarily, I'd use JdbcBatchItemWriter but I see it is limited in writing to 2 seperate tables. I need to write to Person and Address table. Hibernate could write this in one step but I don't see a simialr capability in Spring Bathc. This SO question Multiple itemwriters in Spring batch suggests using a CompositeItemWriter but the issue with

Is there a simple and safe way to convert a PrintWriter into a PrintStream?

倖福魔咒の 提交于 2019-12-09 03:08:18
问题 Is there a clean and simple way to convert an instance of java.io.PrintWriter into a java.io.PrintStream ? 回答1: First obtain an OutputStream from the Writer . See this question Then pass it as argument to the PrintStream constructor: OutputStream os = new WriterOutputStream(writer); PrintStream ps = new PrintStream(os); Update: commons-io 2.0 has WriterOutputStream, so use it. 来源: https://stackoverflow.com/questions/4268353/is-there-a-simple-and-safe-way-to-convert-a-printwriter-into-a