public static void main(String[] args) { // TODO code application logic here
Session session = null;
try{ // This step will read hibernate.cfg.xml
System.out.println("creating session factory");
SessionFactory sessionFactory = new Configuration(). configure(new File("D:\\NetBeansProjects\\Hibernate\\src\\hibernate\\hibernate.cfg.xml")) .buildSessionFactory(); session =sessionFactory.openSession(); //Create new instance of Contact and set
System.out.println("Inserting Record"); User contact = new User();
System.out.println("Done"); }catch(Exception e){ System.out.println(e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.flush(); session.close();