How To Fetch Data From MySQL table In Java Using Hibernate

In this post, I will be showing you how to fetch data from MySQL table and show it in the console of your IDE using Hibernate and Java. If you have chosen Hibernate version 3.0 in your DTD in hibernate.cfg.xml file and if you refer to https://developer.jboss.org/docs/DOC-15062#api . you will find that query execution methods like find(), iterate(), filter() and delete() has been deprecated instead we'll be using createQuery() method. Later in this document, you will also get error for using Query class as it is deprecated but don't worry about it as it will still work. You can also read the document above completely to understand what new features are released and which ones have been removed in newer version. Suppose you have a Student class: @Entity public class Student{ @Id private String id; private String name; //getters and setters here : : : } and you have the following data in your Student MySQL table. ID|Name 1 | Sumit 2 | Am...