Good question without a single simple answer.
I used to be a big fan of Hibernate after using it in several projects in a few years. I figured that any project should default to sleep mode.
Today I’m not sure.
Hibernate (and JPA) is great for some things, especially at the beginning of the development cycle. It is much faster to get to something that works with Hibernate than with JDBC. You get many features for free caching, optimistic blocking, etc.
On the other hand, it has some hidden costs. Sleep mode is deceptively simple at startup . Follow the instructions, add some annotations to your class - and you have perseverance. But it’s not easy, and to be able to write good code in it requires a good understanding of both its internal development and database design. If you are just starting out, you may not be aware of some problems that may bite you later, so here is a partial list.
Performance
Execution performance is good enough, I have yet to see a situation where sleep mode was the cause of poor production performance. The problem is startup performance and how it affects device testing time and development productivity. When hibernation loads, it analyzes all entities and does a lot of pre-caching - this can take about 5-10-15 seconds for a not-so-large application. So your 1 second unit test will now take 11 seconds. Not fun.
Database independence
This is great if you do not need to do fine tuning in the database.
Session in memory
For each transaction, Hibernate will store an object in memory for each row of the database that it “touches”. This is a good optimization when you do simple data entry. If for some reason you need to process many objects, this can seriously affect performance if you do not explicitly and thoroughly clear the session inside the memory.
Cascades
Cascades make it easy to work with object graphs. For example, if you have a root object and some children, and you save the root object, you can configure hibernation to save children. The problem starts when your graph of objects becomes complex. If you are not very careful and well versed in what is happening inside, you can easily ruin it. And when you do this, it is very difficult to debug these problems.
Lazy Loading
Lazy Loading means that every time you download an object, hibernate will not download all related objects, but instead will provide owners with places that will be allowed as soon as you try to access them. Great optimization? This is, except that you need to know about this behavior, otherwise you will receive critical errors. Google "LazyInitializationException" for an example. And be careful with performance. Depending on the order in which objects are loaded and the object graph, you can click "n + 1 selects problem". Google for more information.
Schema Update
Hibernate makes it easy to change the schema, just refactoring java code and restarting it. It's great when you start. But then you release version 1. And if you do not want to lose your customers, you need to provide them with schema update scripts. This means that there is no simpler refactoring since all schema changes must be performed in SQL.
Views and stored procedures
Sleep mode requires exclusive write access to the data it is working with. This means that you cannot really use views, stored procedures, and triggers, as they can lead to data changes when sleep mode is unaware of them. You may have some external processes that write data to the database in separate transactions. But if you do, your cache will have invalid data. This is another thing to take care of.
Single threaded sessions
Sleeping sessions are single-threaded. Any object loaded through a session can be accessed only (including reading) from only one stream. This is acceptable for server-side applications, but can complicate unnecessary things if you are using a GUI-based application.
I think my point is that there is no free food.
Hibernate is a good tool, but it is a complex tool, and it takes time to understand it. If you or your team members do not have such knowledge, it’s easier and faster to go with pure JDBC (or Spring JDBC) for one application. On the other hand, if you are willing to invest time in learning (including learning by doing and debugging) than in the future, you can better understand the trade-offs.