問題
以前の “org.hibernate.cfg.AnnotationConfiguration`”に注目されたHibernate 3.6を使った作業は、 ”
deprecated
“としてマークされています。
__コードスニペット…
import org.hibernate.cfg.AnnotationConfiguration;//... private static SessionFactory buildSessionFactory() { try { return new AnnotationConfiguration().configure().buildSessionFactory(); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } }
コードはまだ動作していますが、廃止された警告メッセージを表示し続けるだけですが、 “AnnotationConfiguration`”の代わりがありますか?
解決策
Hibernate 3.6では、 “org.hibernate.cfg.AnnotationConfiguration`”は廃止され、そのすべての機能は “org.hibernate.cfg.Configuration`”に移されました。
したがって、 ”
AnnotationConfiguration
“を ”
Configuration
“クラスで安全に置き換えることができます。
__コードスニペット…
import org.hibernate.cfg.Configuration;//... private static SessionFactory buildSessionFactory() { try { return new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } }