(1)ヒベルナツ3.3.2準備作業


1.必要なカバンを入れる
 hibernate 3.3.2の発行パッケージをダウンロードして、hibernature 3.jarとhibernate-distributin-3.3.2.GA\lib\requiredの下の6つのjarに加入します。
  http://www.slf4j.org ウェブサイトの上でslaf 4 j-1.5.8をダウンロードしてsf 4 j-nop-1.5.jarに参加します。
 
説明:hibernate-distributin-3.3.2.GA\lib\requiredのsfrajはインターフェースで、slaf 4 j-nop-1.5.jarは実現です。
 
2.hibernate.cfg.xmlファイルを作成し、実体類のマッピングファイルもあります。これらは公式文書で詳しく説明されています。copyは一番間違いないです。
 
3.Session Factory補助類を作成するか、それとも公式文書で作成するか。
 
package org.hibernate.tutorial.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure().buildSessionFactory();
        }
        catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}
 
 
javaeyeでメモをするのは悪くないですね。以前習ったことをまとめて、後で調べるのが便利です。