ドメインモデル VS トランザクションスクリプト
■ このスレッドは過去ログ倉庫に格納されています
008277
2010/03/21(日) 03:18:58ID:mt4VmBGq注文を登録もしくは更新するユースケース
# アプリケーション層
public View hogeAtcion(Model model) {
// 登録、更新で分岐処理
if (model.isNew()) {
hogeService.persist(model);
} else {
hogeService.merge(model);
}
return new View(model);
}
# サービス層
public void HogeService {
// 登録用のサービス
// 他のエンティティをくっつけて、計算して永続化する
publc void persist(Model model) {
model.addOtherEntity(fooService.getOtherEntity(model.key));
model.calculate();
modelDao.persist(model);
}
// 更新用のサービス
// モデルをマネージドにし、関連エンティティを再取得し、計算して更新する
publc void merge(Model model) {
modelDao.merge(model);
model.refreshOtherEntity();
model.calculate();
}
}
■ このスレッドは過去ログ倉庫に格納されています