-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow to use MyBatisPagingItemReader without InitializingBean#afterPropertiesSet #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks you for your suggestion. @Autowired
public AccountReader(final SqlSessionFactory sqlSessionFactory) throw Exception {
pagingItemReader = new MyBatisPagingItemReader<>();
pagingItemReader.setSqlSessionFactory(sqlSessionFactory);
pagingItemReader.setQueryId(QUERY_ID);
pagingItemReader.setPageSize(10);
pagingItemReader.afterPropertiesSet();
} |
I was almost sure to get this kind of answer but let me explain why I disagree with this solution. From the Spring documentation:
So it should be use like said, to customize some object but not the initilization of the class itself. (my understanding) I rather think of an other solution if possible. |
Thanks for feedback! Note: |
close via #331 |
Hi, I am currently using
MyBatisPagingItemReader
along with spring batch in order to read sequentially data from my database.The thing is that with the current implementation of
MyBatisPagingItemReader
, I am constraint to create as many bean as I have requests to do. I am actually not happy with that and I'd like to have some system to create an instance ofMyBatisPagingItemReader
and configure myself like so:This is a dummy example but this is what I am trying to achieve.
Now this is actually not possible because of:
Reference here.
In fact, by instanciating with the constructor and not declaring it as a Bean, Spring wont go through
afterPropertiesSet
andresults.addAll(sqlSessionTemplate.selectList(queryId, parameters));
will throw aNullPointerException
Reference here
What do you think of this ? I could actually do a PR if you want me to try implement this.
Cheers,
The text was updated successfully, but these errors were encountered: