| package com.hibernate.demo; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import com.hibernate.entity.Student; public class CreateStudentDemo { public static void main(String[] args) { //create session factory SessionFactory factory = new Configuration() .configure("hibernate.cfg.xml") .addAnnotatedClass(Student.class) .buildSessionFactory(); //create session Session session = factory.getCurrentSession(); try { //use the session object to save java object System.out.println("Create a new student object..."); Student tempStudent = new Student("Paul", "Wall", "paul@luv2code.com"); //start a transaction session.beginTransaction(); //save the student object System.out.println("Saving the student"); session.save(tempStudent); //commit transaction session.getTransaction().commit(); System.out.println("Done!"); } finally { factory.close(); } } } error: Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 27 and column 20 in RESOURCE hibernate.cfg.xml. Message: cvc-complex-type.2.3: Element 'session-factory' cannot have character [children], because the type's content type is element-only. Caused by: javax.xml.bind.UnmarshalException |