Be a little careful with the link that Rashid posted, while most of it is a good example to see, there are a couple bad practices in there, including probably wanting to use try catches around your unit of works.
e.g (say you have a employee table in a database.and you have mapped that employee table with Employee.hbm.xml in hibernate to the Employee.java persistent class.then use the following code to select details from table. note:u have to keep the Employee.hbm.xml in the classpath of persistent class.and give that description of mapping file .hibernate.cfg.xml)