Hi
I'm trying to insert a record to DataBase, the program run without any exception!
the table is created but, no rows exist!
I used hibernate and mysql.
please someone help me.
here is the code of my main method:
Code:
public static void main(String[] args) {
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
System.out.println("creating table done!");
Person person= new Person();
person.setNationalNumber(12345);
person.setFamily("A");
person.setName("M");
person.setLocation("Tehran");
session.save(person);
}catch(Exception e){
System.out.println(e.getMessage());
}
finally{
session.flush();
session.close();
}
}