Java - DAO+Hibernate+JPA+JDBC+Tomcat+Servlet

Asked

Viewed 208 times

2

I am advancing the Java course and came across DAO, JPA, Servlet, Hibernate and Tomcat. I understand that DAO deals with the database, that Hibernate is a framework for this, that JPA transcribes from object-oriented to entities. Still, that Tomcat and Servlet provide server-side program of type HTML to work HTTP protocol. However, I’m with an application that uses everything and I’m confused how they all operate together! Can anyone help me fit them all together? I don’t need code, but a theoretical explanation of the meaning of how they operate together. Thank you for your help. Do you have any book reference or website that you can enlighten me in detail?

1 answer

2

In DAO you can separate your database access logic from your controller logic, for example.

In the case of a product registration system we would have the following classes: Product, Product, Sessionfactory/Entityfactory.

In Productodao is where we will have the logic of access to bank, the connection of the bank can be made from JPA or even Hibernate, speaking in a very simple way, JPA makes the connection for you, using under the cloths the Hibernate. Then in your DAO you will have a call from a Factory of connection with the bank, can be a Sessionfactory in the case of Hibernate or an Entityfactory in the case of JPA.

JDBC is basically the connection of java to the database, formerly before technologies like Hibernate and JPA we needed to have a JDBC class where we would make all our connection logic and database calls (selects, Inserts, updates, Deletes), using these technologies, have already won these semi logics ready, just call them, as for example the persist(data) of JPA, which will make an entrance in the bank for you.

The Servlets classes allow you to create dynamic web pages. The name Servlet comes from the idea of a small server whose goal is to receive HTTP calls, process them and return a response to the client. Each Servlet is therefore a Java object that takes such requests (request) and produces something (Response), such as a dynamically generated HTML page. And Tomcat is a software that you use to upload your server and deploy your project on it, it is a container of Servlets.

You can follow Caelum’s free courses on web development: Caelum Java web development

If you want to go deeper, you can do this on Web development with vraptor: Caelum Agile web development with vraptor

Just remembering that my explanation was shallow! But I hope I helped =D

  • Gosh, thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.