what is ConnectionFactory...?
Here is the basic steps, using a properties file... which can be modified cfg.configure() to load the cfg.xml file instead (see this other thread for info on cfg.xml vs. properties loading:
http://forum.hibernate.org/viewtopic.php?t=956099&highlight=hibernate+properties
Code:
Configuration cfg = new Configuration();
Properties p=new Properties();
try {
p.load(new FileInputStream(new File("hibernate.properties")));
} catch (IOException e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
System.err.println(e.getMessage());
e.printStackTrace(pw);
System.err.println(baos.toString());
e.printStackTrace();
System.exit(-1);
}
cfg.buildSettings(p);
cfg.addClass(test.proc.AccountSources.class);
SessionFactory sessionFactory = cfg.buildSessionFactory();
Session session = null;
session = sessionFactory.openSession();
Hope this helps some...