Java Reference
In-Depth Information
APPENDIX C
n n n
Hibernate and Spring
T he Spring Application Framework offers developers an environment that ties together
numerous APIs into a coherent whole. Spring applies the philosophy of “dependency injec-
tion” by providing appropriate configurable wrapper classes for all sorts of popular Java
libraries.
The standard Spring API is immense, and its standardized approach to dependency
management means that any existing API can in principle become a “Spring” API. If you
want a good introduction to using Spring, then we recommend the excellent Pro Spring , by
Rob Harrop and Jan Machacek (Apress, 2005). For an overview, visit the Spring web site at
http://springframework.org .
In view of its scope, we cannot and do not make any attempt to teach you even the basics
of the Spring Framework in this appendix—instead, we assume that you are already familiar
with Spring in general, and offer a focused introduction to the Hibernate-related components.
Throughout this appendix, we refer to a simple sample application that represents a
“newsstand” of papers consisting of sets of articles. At the end of this appendix, we include
the complete Spring bean configuration file for the example application; and as with all the
examples in this topic, the entire application itself can be downloaded from the Apress web
site ( www.apress.com ).
Spring Libraries
The Spring Framework essentially provides wrappers and utility classes for working with vari-
ous other frameworks, as well as some of its own implementations. For example, it provides its
own model-view-controller (MVC) patterned web application framework, and also supports
Struts and vanilla JSPs.
Spring is distributed as a small set of JAR files that contain the Spring-specific functional-
ity. The third-party components are made available with the “including dependencies” distri-
bution of Spring, but can also be downloaded independently from their respective web sites.
It is possible to copy all the libraries that Spring is capable of using into the classpath, but
this is a somewhat inelegant approach. We prefer to pick the core Spring JARs and add to them
only what is necessary to support the application being built.
For our example application, we have therefore included the following sets of libraries:
The Hibernate JAR and its required dependencies
The Hibernate Annotations JAR and its required dependencies
299
Search WWH ::




Custom Search