These last days I was finish the first stage of the API that will help us to communicate with a PostgreSQL database using Spring Framework and Hibernate. It had some difficult tasks and (mainly) a lot of concepts that were necessary to understand first. Let’s talk about of some concepts!

Spring

  • Servlet: “A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers” (https://goo.gl/2zC5EY).
  • Web descriptor file: commonly named as web.xml. It is part of the Java Servlet Specification, it is basically the configuration for Java web applications. If you want to learn in detail what offers, please refer to the last servlet specification (3.1) here: https://goo.gl/eKVc2D.
  • Application context: it is like a specific set of configurations that Spring interprets. In my case, it helps us modularize the REST settings (controllers) and database ones (transactions, session factories, data sources) so I created two application contexts to separate both. As default, Spring looks in the WEB-INF (recommended location, see https://goo.gl/S2ohhm) or META-INF folders a file named applicationContext.xml (although the word application can be changed depending on the servlet name, if it is the entry point in the web.xml file).
  • Inversion of Control (IoC): “also known as dependency injection (DI), is a process whereby objects define their dependencies, that is, the other objects they work with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean” (https://goo.gl/GpVzSY).
  • Bean: “In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a bean is simply one of many objects in your application” (https://goo.gl/GpVzSY).

Hibernate

  • Data source: settings describing how establish a connection with a database. The driver type, database URL, username and password are some configurations used here.
  • Session factory: contains information about the number of pool conections, database dialect, maximum and minimun number of active sessions, where are located the mapping files and so on.
  • Transactional: some important feature helping with the stability and integrity of a transaction, allowing rollback if a exception occurs while performing a query.

In a future post, I will describe how we organize the application architecture and some design patterns adopted.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade