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
:
は、私は次の例外を取得します。以前に呼ばれてはいけませんか?
この例外/動作を引き起こす原因は何か。セットアップに何が問題なのですか?