- 追加された行はこのように表示されます。
- 削除された行は
このように表示されます。
!!!Middlegen
http://boss.bekk.no/boss/middlegen/
::Middlege IDE
*http://www.atmarkit.co.jp/fjava/rensai3/eclipseplgn03/eclipseplgn03_3.html
!!!Hibernateの設定ファイルとPOJOソースをリバースエンジニアリングにより生成
::コンテキストメニュー - New - Other
{{ref_image middlegenide01.jpg}}
::項目の入力
{{ref_image middlegenide02.jpg}}
::Generate ボタンを押して閉じる
{{ref_image middlegenide03.jpg}}
::設定ファイルとJavaソースファイルが生成された
{{ref_image middlegenide04.jpg}}
::起動テスト
package jp.dip.typea;
import java.util.Iterator;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class MiddlegenTest {
static Configuration cfg = new Configuration();
static SessionFactory factory;
public static void main(String[] args) {
cfg.configure();
factory = cfg.buildSessionFactory();
Session s = factory.openSession();
Transaction tx = s.beginTransaction();
Integer employeeId = new Integer(200);
Employee employee = null;
employee = (Employee)s.load(Employee.class, employeeId);
System.out.println("EMPLOYEE :" + employee.getFirstName() + " " + employee.getLastName());
System.out.println(" MAIL :" + employee.getEmail());
Set histories = employee.getJobHistories();
Iterator itrHistries = histories.iterator();
while (itrHistries.hasNext()) {
JobHistory history = (JobHistory)itrHistries.next();
JobHistoryPK pk = history.getComp_id();
System.out.print(" DATE : " + pk.getStartDate().toString());
System.out.println(" - " + history.getEndDate().toString());
}
tx.commit();
}
}
::テスト結果
EMPLOYEE :Jennifer Whalen
MAIL :JWHALEN
DATE : 1994-07-01 - 1998-12-31
DATE : 1987-09-17 - 1993-06-17