I use java batch (jsr-352) in wildfly 9.0.1. Processor of step(chunk-based) access to lazy field of entity. When processor want to fetch lazy field I give LazyInitializationException
. When I run it on wildfly 11.0.0.Alpha1 everything works fine.
In wildfly 9.0.1 when I fetch this field using repository there is no problem. How can I do that whitout using repository?
reader:
public Object readItem() {
return answerRepository.findBy(23);
}
processor:
public Object processItem(Object item) {
AnswerEntitiy answerEntitiy = (AnswerEntitiy)item;
//when i call answerEntitiy.getComment() LazyInitializationException throws
return commentRepository.findByAnswer(answerEntitiy); //works fine
}
writer:
public void writeItems(List<Object> items) {
//loops and casting
commentRepository.save(comment); //LazyInitializationException
}
Here is complete error:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.test.AnswerEntitiy.comments, could not initialize proxy - no Session