I am doing this course from udemy .Just a beginner in spring and hibernate. I tried every method available at internet but not working.Everytime the errors points at "SessionFactory factory = new Configuration()"
public class CreateStudentDemo {
public static void main(String[] args) {
// create session factory
System.out.println("Project started");
SessionFactory factory = new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Student.class)
.buildSessionFactory();
// create session
Session session = factory.getCurrentSession();
try{
System.out.println("Creating new student object....");
Student tempStudent = new Student("Paul", "Wall", "paul@luv2code.com");
session.beginTransaction();
System.out.println("Saving the student..");
session.save(tempStudent);
session.getTransaction().commit();
System.out.println("Done!");
} finally {
factory.close();
}
}
}
