I am working with Hibernate to insert the Data and also to get the Data with the same session as shown below
StudentBean st1 = new StudentBean();
st1.setSid(513);
st1.setSname("Ravi)");
st1.setTotMarks(0.0f);
Session sess = factory.openSession();
sess.persist(st1);
StudentBean st2 = (StudentBean) sess.get(StudentBean.class, 510);
System.out.println(st2.getSname());
When i used show_sql true in the hibernate configuration file , and With this lines the output is
Select Query
Hibernate: select studentbea0_.sid1 as sid1_0_0_, studentbea0_.sname1 as sname2_0_0_, studentbea0_.tot_m1 as tot3_0_0_ from student1 studentbea0_ where studentbea0_.sid1=?
Insert Query
insert into student1 (sname1, tot_m1, sid1) values (?, ?, ?)
Could anybody please tell me why the Insert operation is performed last , by the Hibernate Engine , even though Session.persist is above the get Method ??