Middlegen
http://boss.bekk.no/boss/middlegen/
- Middlege IDE
Hibernateの設定ファイルとPOJOソースをリバースエンジニアリングにより生成
- コンテキストメニュー − New − Other
- 項目の入力
- Generate ボタンを押して閉じる
- 設定ファイルとJavaソースファイルが生成された
- 起動テスト
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

YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto
Copyright© 矢木 浩人 All Rights Reserved.