以下のコードはエラーを引き起こしException in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.model.entity.WorkflowProcessEntity.workstations, no session or session was closed
ます。@Transactional
そのため、サービスクラス内でメソッドをラップしましたが、それでもエラーがスローされます。
WorkstationService workstationService = (WorkstationService) ApplicationContextProvider.getApplicationContext().getBean("workstationService");
for (WorkstationEntity workstationEntity : workstationService.getWorkstations(getEntity())) {
registerWorkstation(new ImpositionWorkstation(workstationEntity));
}
WorkstationService.java
@Transactional(readOnly = true)
public Collection<WorkstationEntity> getWorkstations(WorkflowProcessEntity workflowProcessEntity) {
return workflowProcessEntity.getWorkstations();
}
WorkflowProcessEntity.java
@OneToMany(mappedBy = "workflowProcess")
@JsonIgnore
public Collection<WorkstationEntity> getWorkstations() {
return workstations;
}
この関係を正しく照会するにはどうすればよいですか?