Rectangle 27 2

@Dolph, in the simplest term, think of Spring as your application framework at the highest degree. This "framework" provides several "component buckets" where you can easily plug in different types of implementations. For example, for ORM, you may choose to use Hibernate over JPA or TopLink, for front end, you may choose Wicket over Struts or SpringMVC, and so forth.

The whole beauty of this (besides all the goodies stated in other posts) is it allows you easily swap out any of these implementations easily in the future. So, you can essentially rip out Hibernate one day and replace with TopLink, and it will never cause ripple effect to other components.

Another beauty of using Spring is your code becomes less clutter and has loose dependencies with other classes because you spend less time creating new objects yourself, Spring handles that for you. That said, you will quickly realize how easy for you to test your code because your API to be tested becomes very atomic. This is one primary reason why folks get discouraged in writing testcases, because they quickly realize that in order for them to test one API, they have to construct whole lot of things just to test that. Because of that, the whole process is brittle, imagine if you change that API, you need to reconstruct everything before testing it again.

Pro Spring book is good, mentioned by @JLBarros. I like Spring in Action very much. It is very very easy to read when I first got started with Spring. This is probably one reference book that I read from skin to skin.

I like the In Action series, but I wasn't confident in the book after reading the Table of Contents... but then again, I had no idea what I wanted out of Spring, so I didn't know what to look for! The second edition is expected to come out Dec 2010 as well.

The In Action by no means have all the details about Spring. For that you need to refer the springsource website directly because they have the most complete documentation I have ever seen. The In Action helps me to get started right away and the explanations are very easy to understand. When I need more info after that, I will dig around springsource.

java - How does Spring fit into my application architecture? - Stack O...

java hibernate spring web-applications wicket
Rectangle 27 240

  • Spring is an IoC container (at least the core of Spring) and is used to wire things using dependency injection. Spring provides additional services like transaction management and seamless integration of various other technologies.
  • Struts is an action-based presentation framework (but don't use it for a new development).
  • Struts 2 is an action-based presentation framework, the version 2 of the above (created from a merge of WebWork with Struts).
  • Hibernate is an object-relational mapping tool, a persistence framework.
  • JavaServer Pages is a view technology used by all mentioned presentation framework for the view.
  • Struts 2, JSF, Tapestry (and Wicket, Spring MVC, Stripes) are presentation frameworks. If you use one of them, you don't use another.
  • Hibernate is a persistence framework and is used to persist Java objects in a relational database.
  • Spring can be used to wire all this together and to provide declarative transaction management.

I don't want to make things more confusing but note that Java EE 6 provides modern, standardized and very nice equivalent of the above frameworks: JSF 2.0 and Facelets for the presentation, JPA 2.0 for the persistence, Dependency Injection, etc. For a new development, this is IMO a serious option, Java EE 6 is a great stack.

Why did this got downvoted? Anti Java EE 6?

I'd like to point out that in this sort of comparison context some people also use the word Spring to refer to its own MVC framework (which is much nicer than Struts IMO).

@downvoter Leaving a comment when downvoting is much appreciated, it would give me the opportunity to learn something or to fix my answer... at least if it's a technical downvote. If its an emotional downvote (and I think it is here), you should just avoid doing it in my opinion.

Nicely explained, but still it's too technical. I'd advise you to explain it in layman term. Anyways the links at the end did that.

The answer is a great starting point indeed, but could be improved upon by explaining the main concepts introduced (request based vs component based frameworks, IoC containers, Presentation vs persistence framework... ) As it stands now, it requires a lot of additional googeling, but it is still a good answer, and great starting point! Upvote.

java - What is the difference between Spring, Struts, Hibernate, JavaS...

java frameworks java-ee
Rectangle 27 240

  • Spring is an IoC container (at least the core of Spring) and is used to wire things using dependency injection. Spring provides additional services like transaction management and seamless integration of various other technologies.
  • Struts is an action-based presentation framework (but don't use it for a new development).
  • Struts 2 is an action-based presentation framework, the version 2 of the above (created from a merge of WebWork with Struts).
  • Hibernate is an object-relational mapping tool, a persistence framework.
  • JavaServer Pages is a view technology used by all mentioned presentation framework for the view.
  • Struts 2, JSF, Tapestry (and Wicket, Spring MVC, Stripes) are presentation frameworks. If you use one of them, you don't use another.
  • Hibernate is a persistence framework and is used to persist Java objects in a relational database.
  • Spring can be used to wire all this together and to provide declarative transaction management.

I don't want to make things more confusing but note that Java EE 6 provides modern, standardized and very nice equivalent of the above frameworks: JSF 2.0 and Facelets for the presentation, JPA 2.0 for the persistence, Dependency Injection, etc. For a new development, this is IMO a serious option, Java EE 6 is a great stack.

Why did this got downvoted? Anti Java EE 6?

I'd like to point out that in this sort of comparison context some people also use the word Spring to refer to its own MVC framework (which is much nicer than Struts IMO).

@downvoter Leaving a comment when downvoting is much appreciated, it would give me the opportunity to learn something or to fix my answer... at least if it's a technical downvote. If its an emotional downvote (and I think it is here), you should just avoid doing it in my opinion.

Nicely explained, but still it's too technical. I'd advise you to explain it in layman term. Anyways the links at the end did that.

The answer is a great starting point indeed, but could be improved upon by explaining the main concepts introduced (request based vs component based frameworks, IoC containers, Presentation vs persistence framework... ) As it stands now, it requires a lot of additional googeling, but it is still a good answer, and great starting point! Upvote.

java - What is the difference between Spring, Struts, Hibernate, JavaS...

java frameworks java-ee
Rectangle 27 17

Hibernate is used for handling database operations. There is a rich set of database utility functionality, which reduces your number of lines of code. Especially you have to read @Annotation of hibernate. It is an ORM framework and persistence layer.

Spring provides a rich set of the Injection based working mechanism. Currently, Spring is well-known. You have to also read about Spring AOP. There is a bridge between Struts and Hibernate. Mainly Spring provides this kind of utility.

Struts2 provides action based programming. There are a rich set of Struts tags. Struts prove action based programming so you have to maintain all the relevant control of your view.

In Addition, Tapestry is a different framework for Java. In which you have to handle only .tml (template file). You have to create two main files for any class. One is JAVA class and another one is its template. Both names are same. Tapestry automatically calls related classes.

java - What is the difference between Spring, Struts, Hibernate, JavaS...

java frameworks java-ee
Rectangle 27 17

Hibernate is used for handling database operations. There is a rich set of database utility functionality, which reduces your number of lines of code. Especially you have to read @Annotation of hibernate. It is an ORM framework and persistence layer.

Spring provides a rich set of the Injection based working mechanism. Currently, Spring is well-known. You have to also read about Spring AOP. There is a bridge between Struts and Hibernate. Mainly Spring provides this kind of utility.

Struts2 provides action based programming. There are a rich set of Struts tags. Struts prove action based programming so you have to maintain all the relevant control of your view.

In Addition, Tapestry is a different framework for Java. In which you have to handle only .tml (template file). You have to create two main files for any class. One is JAVA class and another one is its template. Both names are same. Tapestry automatically calls related classes.

java - What is the difference between Spring, Struts, Hibernate, JavaS...

java frameworks java-ee
Rectangle 27 4

  • JSF is built on top of JSP/Servlet -- it's not really a replacement, but a higher level abstraction.
  • Ideas in Hibernate and Spring have somehow been integrated under JPA and CDI.
  • Basic knowledge of JSP/Servlet is still usefull, what's not needed is knowledge of JSTL.

That said, there are two broad categories of web framework: component-based, and action-based. JSF is component based and each component is responsible of its own rendering and callbacks. Struts is action-based, where the controller forward to a view explicitly. Both can be seen as MVC, but the approach differ largely between the two. There are other frameworks of both types around (wicket, play, etc.)

java ee - JSF 2.0 (Facelets) and Struts - Stack Overflow

jsf java-ee struts2 facelets jsf-2
Rectangle 27 0

With Struts 2 I tend to use normal S2 action properties to gather form values/etc. and use BeanUtils to copy them to the Hibernate objects. The problem with exposing the Hibernate objects to the form, like with ModelDriven etc. is that you need to define whitelists/blacklists if you have columns that should not be set directly by the user. (Or handle the problem in a different way.)

That said, I'm not fundamentally opposed to the idea like a lot of people are, and they're arguably correct.

agree but in some cases i have large number of properties and putting properties inside action class is like aking action class very populated

@user702325 Then either use the Hibernate model, or use source generation to create a POJO with only the properties you want and use ModelDriven. Not sure what you were really asking, I guess; you can use the action itself, or a model. Sounds like you already made up your mind regarding which way to go.

i have not come up with aything yet, but i do know the problem using hibernate pojo at action level so even i am bit inclined towards creating DTO/POJO for action level and than mapping thme to the hibernate POJO

java - POJO or DTO approach - Stack Overflow

java hibernate architecture dto pojo
Rectangle 27 0

Just try to work with both scopes and choose one preferred for yourself. But I should say there is small difference when you are working with persistent objects (and ORM tools like Hibernate), just because properties are persisted in database between requests.

As you can see, there is only one disadvantage with session-scoped form bean, and it arises only in relation to serious design flaw (overlapping update requests from one user).

design - Disadvantages to define a form bean with session scope in str...

session design struts struts-1
Rectangle 27 0

Just try to work with both scopes and choose one preferred for yourself. But I should say there is small difference when you are working with persistent objects (and ORM tools like Hibernate), just because properties are persisted in database between requests.

As you can see, there is only one disadvantage with session-scoped form bean, and it arises only in relation to serious design flaw (overlapping update requests from one user).

design - Disadvantages to define a form bean with session scope in str...

session design struts struts-1