Nearby lessons

4 of 19

Hibernate - Retrieving Records from the Database

📌 What You Will Learn
  • Understand Hibernate - Retrieving Records from the Database
  • See working code examples
  • Learn from common mistakes and Q&A

Learn Hibernate - Retrieving Records from the Database step by step — simple explanations, complete programs with their output, common beginner mistakes, and exam-style MCQs.

Retrieving Records from the Database

  • } catch (Exception e) {
  • e.printStackTrace();
  • }finally {
  • session_Factory.close();
  • session.close();

HIBERNATE with My SQL Database

If we want to use MySQL Database for Hibernate applications then we have provide the following changes.

In Hibernate Configuration File: : com.mysql.jdbc.Driver Driver Class Name : jdbc:mysql://localhost:3306/db_Name Driver URL : root DB User Name : root DB Password : org.hibernate.dialect.MySQLDialect Dialect

Note: We must add mysql-connector-java-5.0.8-bin.jar file to Hibernate3_Lib.

In Hibernate Applications, it is not suggestible to manage Configuration object and SessionFactory object in Client Application directly, because, these two objects are providing Hibernate Boot strapping. In futer if we want to change boot strapping mechanisms then we have to provide changes in Client Application, it may effect our persistence operations. To avoid this type of problems we have to use a separate Utility class to prepare Configuration and SessionFactory object.

Example02
Loading editor…

HIBERNATE with My SQL Database — Employee.java

Example:

Example03
Loading editor…

HIBERNATE with My SQL Database — Employee.hbm.xml

Example04
Loading editor…

HIBERNATE with My SQL Database — hibernate.cfg.xml

Example05
Loading editor…

HIBERNATE with My SQL Database — HibernateUtil.java

Example06
Loading editor…

HIBERNATE with My SQL Database — ClientApp.java

Example07
Loading editor…

AWT/GUI-Hibernate Integration Application — Student.java

Example08
Loading editor…

AWT/GUI-Hibernate Integration Application — Student.hbm.xml

Example09
Loading editor…

AWT/GUI-Hibernate Integration Application — hibernate.cfg.xml

Example10
Loading editor…

AWT/GUI-Hibernate Integration Application — HibernateUtil.java

Example11
Loading editor…

AWT/GUI-Hibernate Integration Application — StudentService.java

Example12
Loading editor…

AWT/GUI-Hibernate Integration Application — SearchFrame.java

Example13
Loading editor…

AWT/GUI-Hibernate Integration Application — ClientApp.java

Example14
Loading editor…

Servlet_Hibernate_Application — loginform.html

Example15
Loading editor…

Servlet_Hibernate_Application — success.html

Example16
Loading editor…

Servlet_Hibernate_Application — failure.html

Example17
Loading editor…

Servlet_Hibernate_Application — hibernate.cfg.xml

Example18
Loading editor…

Servlet_Hibernate_Application — User.hbm.xml

Example19
Loading editor…

Servlet_Hibernate_Application — HibernateUtil.java

Example20
Loading editor…

Servlet_Hibernate_Application — User.java

Example21
Loading editor…

Servlet_Hibernate_Application — UserService.java

Example22
Loading editor…

Servlet_Hibernate_Application — LoginServlet.java

Example23
Loading editor…

Servlet_Hibernate_Application — web.xml

Example24
Loading editor…

JSP_Hibernate_Application — searchform.html

Example25
Loading editor…

JSP_Hibernate_Application — notexisted.html

Example26
Loading editor…

JSP_Hibernate_Application — display.jsp

Example27
Loading editor…

JSP_Hibernate_Application — search.jsp

Example28
Loading editor…

JSP_Hibernate_Application — Customer.java

Example29
Loading editor…

JSP_Hibernate_Application — Customer.hbm.xml

Example30
Loading editor…

JSP_Hibernate_Application — hibernate.cfg.xml

Example31
Loading editor…

JSP_Hibernate_Application — web.xml

Example32
Loading editor…
📝 Key Takeaways
  • Key ideas of Hibernate - Retrieving Records from the Database explained simply
  • Ready-to-use code examples
  • Exam-style questions at the end

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.