Retrieving Objects using session.get()

In this post we will retrieve the record that we have inserted in previous post

As SessionFactory is one per application and its very expensive we will use the same sessionFactory object which we used to save the record and get a new session from it to retrieve the record.

session.get(UserDetails.class, 1); method takes two parameter,First is the Model class and the second is the primary key to fetch the record.

In Hibernate all the operation we do on the Model object and not the Table.


   

Comments are closed