views:

2976

answers:

13

Hi guys, I've just started learning Struts and I'm trying to be marketable for a good job as a Java programmer. My next decision would be choosing which to learn next, Spring or Hibernate?

Also do you guys have any suggestions or tips for me to be good? Thanks in advance!

+30  A: 

I'd suggest learning Spring. Learn just the basics, and then when you do come to learn Hibernate you'll be able to take advantage of all the Spring helpers which make Hibernate easier to use.

There's also the point that Spring is useful in many layers instead of just at the data access part :)

Jon Skeet
+3  A: 

I think Hibernate is fairly easy and straighforward to get basic usage skills in, and perhaps more importantly, the EJB3 is becoming a standard.

Spring is an external technology, not part of J2EE officially, so it might make sense to do it second, it also has a lot more facets and you really want a good book for it.

Uri
+9  A: 

Spring and Hibernate are 2 very complimentary technologies and depending on the needs you may use both, either or none. But the fundamentals both of these frameworks rely upon are 100% marketable and more importantly are required for any seasoned professional.

There is little value in learning Hibernate without first obtaining fundamental knowledge on relational data modeling, relational database design, and transaction processing. So these should be your pre-requisites for Hibernate.

There is little value in learning Spring without first obtaining fundamental knowledge on design patterns, dependency injection, and application design (as general as it sounds you need to understand things like application tiers, class and package dependencies, MVC (sounds like you are familiar with this one via Struts), security and web standards, and of course fundamentals of OOD).

By learning both you will become if not marketable but at least very solid professional who is confident and comfortable in working on majority of Java (and not just Java) applications.

grigory
Actually the things you've mentioned as prerequisites, I'm not familiar of those. It seems daunting to be honest.
ajushi
grigory makes some good points. Without understanding the concepts behind the technologies you'll likely use them in ways they were not intended or designed. These are both popular frameworks but they do not solve all problems. The prereqs may be daunting at 1st, but they'll make you a better dev.
Kevin Williams
Hi Kevin, how would you suggest I try to tackle those prerequisites?
ajushi
Fundamentals of OOD, data modeling, and transaction processing are first. Then you can follow up with the rest and at the same time start either Hibernate or Spring depending on where your priority is: database development (Hibernate) or general app. development (Spring)
grigory
Any books or resources for OOD, data modeling, and transaction processing?
ajushi
OOD - Object-Oriented Analysis and Design with Applications by BoochData Modeling - Data Modeling by SandersTransaction Processing - Principles of Transaction Processing by Bernstein and Newcomer
grigory
A: 

First I learned Hibernate. Used groovy to try out different Hibernate examples. Then learned Spring and its Hibernate support. I think I had a really interesting journey.

Here is an example of Struts+Spring+Hibernate application. Struts for front-end, Spring for middle layer and JPA/Hibernate for persistence layer.

http://struts.apache.org/2.0.11/docs/struts-2-spring-2-jpa-ajax.html

Manoj
A: 

I learned Hibernate by itself first, and then I learned how Spring makes it much easier.

Gary Kephart
+3  A: 

Spring is far bigger and more generally applicable than Hibernate is. You decision is a trade-off between the length of the learning curve and the utility you'll have when you're done.

I'd recommend Spring, because it can either co-exist with both Struts and Hibernate OR supply alternatives for either one (Spring web MVC and Spring JDBC).

Spring will have a beneficial effect on your Java EE designs. Start with that.

duffymo
+1  A: 

I would go with Spring first. Spring has so many different pieces that are useful: dependency injection, aspect-oriented programming, JDBC helper classes, an entire MVC framework and loads more. You can use as little or as much of Spring as you want on your first application and the reference documentation is truly excellent. You can easily learn Spring without buying even a single book on it.

cliff.meyers
A: 

I would consider to learn them both at the same time. Spring and NHibernate are both large frameworks with a high learning curve. It will take you some studying and experimenting time to become familiar with and good at it. When you are busy with both the frameworks, you will automatically focus on the most useful parts of them first. Learning the important parts first will make the learning curve steeper.

Paco
A: 

I think you should share your profile in a brief to get a better answer

However... Both hibernate and spring are hot and you will find them in all job requirements posted for enterprise applications- so you are on the right track as far as your selection choices is concerned.

IMHO- hibernate is trickier than Spring The reason for that is- Spring by virtue of its architecture is least invasive to the code There is little API to master. So to code in Spring- you don't have to really code anything beyond Java But to code hibernate- you need to know the Hibernate APIs and the gotchas of hibernate programming. The basics of hibernate are easy to master- but to learn the tricks and trivias- it takes time

If I was the hiring manager and were using hibnernate and Spring I would rather take someone who was stronger on Hibernate rather than someone who was stronger on Spring As far as spring is concerned- you as a contributing programmer- will have little to worry about Most likely the application will already have a framework in place- and you will have to plug in your contributions in.

But to code in hibernate- like I said before- its better if you have soem experience on this

PS: I know everyone has a different viewpoint on this- so you maybe getting more confused .I think- once you share a bit of your profile- it will help people give you a better advice. Good luck !!!

RN
+1  A: 

I wouldn't go for Struts these days.. If you're already considering Spring you should also take a look at Spring MVC, especially the newer Annotation-based Controllers are really nice to work with.

I would suggest learning Spring before Hibernate because it is much easier to learn if you stick to the core and maybe WebMVC, which is what I would recommend. Spring grew quite a bit in the last releases but the core is still simple and easy to understand.

Hibernate is a lot more complicated. I would recommending understanding the general purpose of an ORM like Hibernate, learn the hibernate annotations way of configuring hibernate and then go straight for the Spring/Hibernate Integration because it makes many things much easier. If your domain has more than just a few base types, you could also take a look at the GenericDAO pattern

fforw
A: 

Hi, if you need both technologies Spring Live all you need. I've started learning that technologies from completely zero :)

zaletniy
A: 

If the objective it to learn MVC framework and how to use ORM with that framework, then logical way to learn is Spring and then Hibernate. In my opinion, in that way you will be able to grasp the concepts easily

Paras
A: 

I suggest you to fist learn hibernate and then go for spring.. Follow this link http://www.vaannila.com/hibernate/hibernate-example/hibernate-tools-1.html

taher