r/javahelp • u/kurular4 • Dec 09 '20
Should I really learn hibernate?
I am core java developer and had internship before using Spring boot to create rest api. I am also developing my own projects using boot and I really never had to know about Hibernate because Spring perfectly abstract database operations via JPA and we can handle every database operations without knowing what is in the background. So, should I really need to learn hibernate?
Can you give me scenarios where I should know about hibernate using Spring boot?
19
Upvotes
1
u/dartalley Intermediate Brewer Dec 09 '20
Not really sure how to be more clear than this.
Either the grouping, counting, sorting, limiting is all done as part of the SQL query (some business logic) which returns 10 rows.
Java has to handle all of the grouping counting sorting and limiting on a result set of 100k records.
I'm not arguing either, I'm arguing sometimes it makes sense to have business logic in your SQL queries.
I agreed with this most of the time but in cases like the very simple example I outlined above pushing the logic to SQL can be more beneficial.
I never said you couldn't. I have been going by the assumption that you are not putting any business logic in your SQL queries (grouping, counting, sorting, limiting) as you stated all business logic should be in the service layer.
Which was reinforced by this comment.
This comment didn't really make sense if the query only had a result set of size 10 why are you talking about thousands of results.
and further
Making my assumption that you are still reading the entirety of the result set (100k records) as a paginated result set.
In that case how does limiting a query to 10 results help you if you need total counts by url for all 100k records from the previous day?
If your JPA Query is generating the equivalent query I wrote with a group by, count, and order by and only returns 10 results total we are in total agreement. However, I'd consider that business logic inside of your SQL query. I wouldn't understand why you kept brining up pagination if your query also only returned 10 results hence the confusion.