I will give you a solution, but you need to learn Java programming language before going into Hibernate. It could be very useful :D
Code:
session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(6);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_");
session.save(contact);
transaction.commit();
System.out.println("Done");
This would compile. Still, I think that the advice given by
stliu is a total nonsense, so it would be very interesting to hear from you if it helped.