0
jersey
및 spring boot jpa
을 hibernate
으로 사용하여 나머지 API를 통해 데이터베이스를 쿼리하려고합니다. 스프링 부트 + jpa + 저지가 프록시 초기화 할 수 없음 - 세션 없음
public SomeValue doSomething(String param) {
MyEntity entity = myService.queryDB(param);
return conv.convertEntity(entity);
}
내 서비스 :
엔티티
@Transactional
public MyEntity queryDB(String param) {
return myRepo.findOne(param);
}
:
:
@Entity
MyEntity {
@Id
@NotNull
private String Id;
@OneToMany(mappedBy="foreignKey", fetch = FetchType.LAZY)
private Set<SomeOtherEntity> someOtherEntity;
}
은 심지어 명시 적으로 application.yml의 속성을 설정나는 봄의 OpenEntityManagerInViewInterceptor
의 preHandle
방법은 내가 저장소에 전화를 걸 다음에 호출되는 것을 볼 수 있습니다 디버깅하는 동안
failed to lazily initialize a collection of role: entitites.MyEntity.someOtherEntity, could not initialize proxy - no Session
:
나는 다음과 같은 예외를 얻을. 전에 부르면 안되니?
이 예외/동작을 유발할 수있는 원인은 무엇입니까? 내 설정에 어떤 문제가 있습니까?