私たちのプロジェクトには、レイヤーアーキテクチャがあります。DAOレイヤーはデータベースと通信し、保存されているエンティティを取得します。Service-LayerはDAO-Layerと通信してエンティティを取得し、より複雑なメソッドを実装します。次に、View-LayerはSerivce-Layerと通信して、必要な情報を取得します。
エンティティの一部:
@Entity
public class Operation implements Serializable {
private Integer id;
@GeneratedValue
@Id
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
private List<Participation> participations;
@OneToMany
public List<Participation> getParticipations() {
return participations;
}
public void setParticipations(List<Participation> participations) {
this.participations = participations;
}
DAO-レイヤー:
@Override
public Operation read(int id) {
return this.em.find(Operation.class, id);
}
サービスレイヤー:
@Override
public Operation getOperation(Integer operationId)
{
Operation operation = operationDAO.read(operationId);
//operation.getParticipations();
return operation;
}
ビューレイヤー:
Operation o = opService.getOperation(operationId);
ビューレイヤーに参加せずにこれを使用するoperation.getParticipations();
と、参加リストがありません。愚かなコードを追加すると、オブジェクトが正しく転送され、参加リストが利用可能になります。
オブジェクトが正しく転送されない理由を自分自身に説明することはできませんか?手伝って頂けますか?事前にThx。
編集:オブジェクトの他のすべての属性/フィールドは正しく転送されます(知っておくことが重要かもしれません)