I am planning to set up a new Web-application that contains the following things:

I want to use JavaEE with JSF for the Frontend & Backend combined with git-hooks to deploy them onto my server. Also it seems to be useful to integrate the Spring-Framework whenever you use JEE. Now additionally, I need some database interaction. Now I have two possibilities:

  1. Set up an Rest-API combining Java, Hibernate and Spring (at least that is what my research told me).

  2. Simply add a Hibernate layer to my application.

Why would you use method 1? So for me, there are the following things to do when picking this method:

  • Communication with JSON, so you need a mapper on both sides
  • Since I want to pass objects, I would need to define a class (lets say "book") on both servers - wouldn't that be redundant?
  • Include security mechanisms for the API
  • Set up an additional server for the service

In method 2, I would not need any mappers or security mechanisms for the connection to the API, or did I get that wrong? So why would people use the method 1?

  • Not sure I understand how method 1 would imply requiring an additional server. The backend can communicate to a database on the same server or connect to another server. It's arbitrary for both methods in either case. – Neil Oct 12 at 12:26
up vote 0 down vote accepted

The answer for such question cannot be short, so let's start with the terms:

  1. frontend - software subsystem directly interacting with user. In consumer applications term "frontend" usually refers to an application running in a web browser or to a mobile application.
  2. backend - software subsystems that do not interact with user directly. As a backend software developers usually consider the application server or microservice plus a database and related services (e.g. message queue or distributed cache).
  3. JavaEE - is no longer known as such. Modern name for this technology stack is JakartaEE (https://www.jakarta.ee) This is a group of specifications of various APIs in Java, which greatly vary in popularity and use: pure JEE project today is not a common thing - according to many surveys, only Servlet and JPA APIs are widely used as part of Spring/Hibernate combo.
  4. JSF - more often hated than loved UI framework that is in steady decline for last 5 years due to limitations of its architecture. I would not recommend to start a new project on JSF and look for a more mainstream solution.
  5. A layer in software architecture - logically separated part of the application that performs a specific role. In Java applications layers are typically represented by specific packages or even jar modules. One of the examples of layers is persistence layer, which represents an object-oriented abstraction of a database. By definition layer is not a separate application, so your option 1 does not make sense as a solution to interact with database. Hibernate as a database layer however does make sense. Please note, that Hibernate is a popular implementation of JPA API from JEE, so if you are already on JEE stack, you either already use it or don't need it, because you use some other implementation (e.g. EclipseLink).

Now, let's talk about the architecture in general. Your option 1 is a modern and the most popular solution for the whole application. Spring is a framework of choice for majority of Java developers according to recent surveys (including SO), with more and more of them choosing Spring Boot as a complete technology stack and alternative to JEE. Hibernate is one of the popular options for persistence there, but there are others - check the Spring Boot reference guide (https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/).

Building a REST API on the backend (Spring Boot/Hibernate), that can be consumed by your frontend is one of the easiest ways to develop interactive web applications today, but of course not the only one - choice of the particular solution should always be based on business requirements. For web applications displayed in browser the frontend is usually written on JavaScript or related languages (e.g. TypeScript) with one of the many frameworks that exist there (check Angular and ReactJS).

The considerations for option 1 that you mention:

  • JSON mapping is pretty straightforward. In the frontend it's automatic, in the backend easily implemented with the libraries like Jackson - comes out of the box with Spring Boot.
  • You will have just one server, either providing REST API to JS-based frontend or implementing server-side rendering (in JEE via JSF/JSTL, in Spring Boot - with Thymeleaf).
  • Security is a business requirement. If you need to protect some data, implementation of it must be present. With Spring you can use Spring Security with various options.
  • Thanks for that answer! I did not really know JakartaEE, but I am having a look at it. Also I am going to have a look at Spring Security. Why did I think about JSF? Because it has Primefaces with it which was familiar to me. Now (what I did not know earlier) is that there is also PrimeNG working with Angular instead of JSF. – Rüdiger Oct 15 at 12:07
  • @Rüdiger I personally will not use JSF in any new project: for server-side rendering I use Thymeleaf, for client-side - Angular (as I can see PrimeNG looks good here). Both options, together with Spring Boot, have very low entry barrier and it's very easy to bootstrap quite complex app with them. – Ivan Gammel Oct 15 at 16:28

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.