Good day! I am making a registration form for a web application. How easier is it to implement data storage in mysql: using JDBC or hibernate?

  • 2
    "Easier" - on the fact that you know, If your application consists of one registration form, the answer is obvious. - enzo
  • please) open your own obviously to me as a newcomer to this business) - Serhei Ivanov
  • 2
    Hiberneit runs on top of JDBC. This is a great ORM framework. You try to do on that, and on the other, and choose. Do not be offended, just questions in this formulation does not make sense. The choice of technology stack is made on the scale of the project as a whole, and not on the basis of "I need one mold here." One form without a difference on what to write. - enzo
  • I understood) thanks) - Serhei Ivanov
  • @enzo is not all the same, you wrote in the first message that the choice is obvious, and it is still obvious - JDBC, unless the goal is to study jpa or it is only the first form in the future of a huge project - Stranger in the Q

1 answer 1

So would divide the decisions on the level of abstraction:

Level 0 is the lowest in Java JDBC (all subsequent ones work on top of it) - you practically work with pure SQL. Cons: you need to do a lot with your hands - especially error trapping. Pros: You control everything - especially when and what goes into the database

Level 1 - eliminates a number of shortcomings of the previous level of abstraction - first of all error handling
SpringJDBC is an improved JDBC which eliminates many of the drawbacks of working with pure JDBC (above all error handling)
iBatis, jOOQ - also easy frameworks

Level 2 - tough decisions

Hibernate - the main solution, with which you can significantly reduce the code of CRUD operations (create, read, update, delete) Minuses: you lose control of what goes into the database (queries to the database can become terrible), as a result, there can be performance problems; also this framework needs to be studied - because besides the knowledge of sql, now you need to know a lot of things, otherwise you will not be able to understand the strange errors

Pros: it is easier to switch to another database, less sample CRUD code
TopLink - Alternative ORM

Level 3
JPA is another level of abstraction - over Hibernate, TopLink, ... More precisely, this is a standard that is mainly based on Hibernate

Level 4
SpringData - even further "into space" - an abstraction that allows you to simultaneously work with relational and non-relational databases

This is of course a very conditional division, because all frameworks evolve. And there are not so many here, because I don’t undertake to list everything.

  • JPA - это еще один уровень абстракции - над Hibernate, TopLink, ... Точнее можно сказать, что это стандарт, который в основном основан на Hibernate - ??? - Stranger in the Q
  • JPA is an API, and Hibernate its implementation is Stranger in the Q
  • Well, Hibernate is not only JPA. Of course you can describe the story from EJB version 2 here and why JPA originated (would not Hibernate have been JPA?) - but this is probably too much for an answer - dSH
  • historically yes, hibernate will celebrate 20 years soon, however, and jpa is now not one single hibernate :), in general, I would not write like you :) - Stranger in the Q