• Post Reply Bookmark Topic Watch Topic
  • New Topic

About the JSF,Hibernate and Spring??

 
Aioria sun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
I am currently working on a project which i thinking of using JSF and Hibernate. JSF for display layer, and Hibernate is just for the persistent layer. Then i tried to find out how to put them work together. However, i found that lots of examples on the Internet is about JSF + Hibernate + Spring. It seems that JSF can not just work with Hibernate. Spring is needed. I know nothing about Spring, so what is Spring? what is this framework do? Why people like to put it to work with JSF and Hibernate? any helps is appreciate!!! thanks~~
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any thoughts that JSF or Hibernate need Spring is just pure nonsense.

JSF is your front end. Hibernate manages persistence. The two can talk directly to each other, or you can layer your application.

Spring can sit in the middle and help out the conversation, but it certainly doesn't need to. I've worked on many Hibernate and JSF projects. Only a small percentage used Spring.

Use the right tools for the job. Don't get into 'framework bloat' just because everyone else is doing it.

-Cameron McKenzie
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spring is a framework whose primary purpose is to allow you to construct and wire together JavaBeans. There's a core component, designed to be lightweight, and then there's add-on components for specialized functions such as ORM support (including Hibernate and JPA).

There's no absolute requirement that an app use Spring, but there are some advantages. For one, since the bean instances and relationships managed by Spring can be controlled by an external configuration file, you can make plug-replaceable components and swap test components in and out. I've got a dummy emailer in one app right now. For testing it just dumps the generated emails to the log. In production, I'll wire in the production mailer and it can begin actually transmitting mail.

One of the best reasons for using Spring with an ORM - or even raw JDBC is that its persistence component takes care of a lot of grunt work. There are certain things that you have to do over and over again when dealing with persistent store, and I've seen a lot of sloppy code on that account - especially leaky JDBC connections. Spring obviously can't keep people from writing sloppy code, but its persistence wrappers can at least ensure that the sloppy code doesn't leak connections. Additionally, Spring provides abstract transaction management which meets or exceeds things that would either be even more grunt work or require EJBs, and it does so for environments where pre-V3 EJBs weren't supported.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!