hibernate4 -----AnnotationConfiguration类过期
Java code
package com.user.util;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.[del]AnnotationConfiguration[/del];
public class HibernateUtil {
public static SessionFactory sessionFactory;
static {
try{
sessionFactory = new AnnotationConfiguration().configure().[del]buildSessionFactory();[/del] }catch(Exception e){
e.printStackTrace();
}
}
public static SessionFactory getSessionFactory(){
return sessionFactory;
}
}
AnnotationConfiguration在hibernate 4版本中过期 请问是用那个代替了 而且在hibernate 4中找不到 AnnotationConfiguration这个类。代码中的[del][del]代表删除线——
------解决方案--------------------
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
SessionFactory sf = configuration.buildSessionFactory(serviceRegistry);