私の使用例は以下の通りです:私は、休止状態を使用しているプロジェクトを継承しました。私が今焦点を当てている主体は、この練習の目的のために、が変更に閉鎖されています。練習の目的は、レガシーエンティティの使用を、新しい要件に適した無関係な実装に置き換えることです。どのようにしてエンベロープをリバーセルするか?
目的は、古いエンティティから新しくに機能を移動できるようにすることです。いくつかのhbm.xmlファイルでオフに隠された
ようになり、従来のエンティティの使用は、構成の魔法で
//...
final Session currentSession = sessionFactory().getCurrentSession();
{
LegacyEntity oldAndBusted = get(currentSession, "12345");
oldAndBusted.change(...);
put(oldAndBusted);
}
}
LegacyEntity get(final Session currentSession, String businessId) {
return (LegacyEntity) currentSession
.createQuery("from PurpleMonkeyDishwasher where businessId = ?")
.setParameter(0, "12345")
.uniqueResult();
}
void put(final Session currentSession, LegacyEntity changed) {
currentSession.saveOrUpdate(changed);
}
のようになります
<class name="LegacyEntity" table="PurpleMonkeyDiswasher">
<!-- stuff -->
</class>
どのように私は新しいのための類似のコードを配置します同じテーブルにマッピングされたエンティティ
BuzzwordCompliantEntity get(final Session currentSession, String businessId);
void put(BuzzwordCompliantEntity changed);
まだ私たちのコードパスを壊すことなく同じプロセスでLegacyEntityを作成していますか?
移行中に非常に注意してください。 – Kayaman