What Should I Learn First Spring or Hibernate? A Practical Explanation
Hey there, how are you doing?
Welcome to scaleyourapp.com
In this write-up we are going to discuss the frequently asked question what should I learn first? Spring? Or Hibernate? I am going to talk about how do they fit in when writing web applications. What should be right, the most helpful & easy way to go about learning these techs.
So, without any further ado.
Let’s get on with it.
How do Spring & Hibernate Fit in A Web Application?
Spring & Hibernate are the two most popular frameworks for writing web applications in the Java ecosystem. They go hand in hand & the combination is widely used in the industry.
Spring helps us implement an MVC Model View Controller design, implement the REST API, handle transactions, design the business & the service layer, apply AOP & a lot more.
On the other hand, Hibernate manages data persistence, also called the DAO layer. It interacts with the object model & manages all the data persistence functionality.
So, this is a very high-level view of what both technologies do. The diagram below shows different layers of a web application & where both the frameworks come into effect.
What Should I Learn First? Spring? Hibernate?
I know you are a very smart person & by now you have already figured out that technically it’s favourable to learn Spring first.
When writing a web application & especially when working with a relational database like MySQL, the first thing we need to do is design the data model, database schema, we need to be aware of the relational database modelling techniques. We do not need Hibernate for that.
After the database schema is designed, we start writing the object model & then implement different layers of the app such as the controller, service etc.
We need Spring for that. We need to create an interface, write REST API, annotate controller methods, interfaces, service layer etc.
For all this we need Spring.
P.S Hibernate has not come into the picture yet.
After we are done with the basic skeleton of the app, the basic client to the controller to the service layer flow works fine, we need to persist data.
Now we begin configuring Hibernate & annotating relationships in the object model.
Well, people may have different styles of implementing apps, but the way I have stated is the defacto way of designing web apps with Spring Hibernate.
All the object models & the business logic is written in core Java.
Until & unless we need persistence in the application we do not need Hibernate. No persistence requirement, no need for Hibernate.
Also, some devs just prefer to use plain lightweight custom JPA implementations or Spring Data JPA.
In not so recent past, Struts framework was used with Hibernate in the industry but not anymore. Almost all of the legacy projects have been migrated to Spring.
What Should I Learn First If I am Looking for a Job?
If you are looking for a developer job in the Java ecosystem. Knowledge of Spring is a MUST. There is no hems & haws, no workarounds, you have to learn Spring.
The company you are applying to might not even need Hibernate knowledge sometimes. Do check out the Spring framework Jobs on StackOverflow
So, I think by now you are pretty clear on what you should be learning first.
How much time does it take to learn both? What are the pre-requisites? I’ll cover in a separate write-up. You can read how long does it take to learn Java?
More On the Blog
Well, Guys!! This is pretty much it on what framework you should learn first. If you liked the write-up do share it with your folks.
I would love to know your thoughts on this, don’t forget to let me know in the comment section. If you have any more questions do let me know.
You can follow scaleyourapp.com on social media, also subscribe to the browser notifications to be notified of new helpful content published.
I’ll see you in the next write-up.
If you are a developer and find it hard to cope with constant changes in technology. You are sick and tired of it. You are looking for ways to jump off that endless upskilling treadmill staying relevant and hireable.
You might want to check out my course, DEVELOPER’S ROADMAP TO EXCELLENCE AND FINANCIAL INDEPENDENCE, where I share with you the roadmap and techniques that I follow to keep my sanity in this ever-changing world of software development without killing myself. In it, you’ll find actionable advice and critical points that will enable you to make informed career decisions and accelerate your career at MACH speed.
- Distributed Systems and Scalability Feed #2
- Application Hosting – How PolyHaven Manages 5 Million Page Views and 80TB Traffic a Month for < $400
- The Technology Upskill Mess For Application Developers
- Low Code: The Only Article You Will Ever Need
- No Code: A Profound Insight For Citizen and Professional Developers