This essay developed out of conversations I've had with several other programmers about why Java smelled suspicious. It's not a critique of Java!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Spring Framework Overview
Benefits of Spring Framework
Installing and downloading
Spring Framework
Whats new in spring 2.0?
Introduction to IOC
Setter Injection
Constructor Injection
Spring MVC
Spring and Hibernate
Spring Web Framework
Spring Web Flow
Spring AOP
Register now to recieve special alert and latest technology news!
Spring and Hibernate
Spring can simplify your Hibernate application. Spring's Hibernate integration uses the same generic transaction infrastructure and DAO exception hierarchy that it uses for JDBC, JDO, iBATIS, and TopLink, making it easy to mix and match persistence methodologies if necessary.
There are two approaches to Spring's Hibernate integration:
- Inversion of Control with a HibernateTemplate and Callback
- Extending HibernateDaoSupport and Applying an AOP Interceptor
The IoC/HibernateTemplate methodology feels a lot like the JdbcTemplate methodology described in the last section. For this example, I will show the HibernateDaoSupport/AOP Interceptor approach.
After you have written your standard Hibernate mappings, there basically three things that you need to do to use Spring's HibernateDaoSupport to implement a DAO:
- Configure the Hibernate SessionFactory
- Extend your DAO Implementation from HibernateDaoSupport
- Wire in Transaction Support with AOP
So let's do another implementation of the WidgetDAO using Hibernate. First of all, here is our Hibernate XML mapping for the Widget class:
<?xml version="1.0"?><!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.sample.springrecipes.model">
<class name="Widget" table="WIDGETS">
<id name="id" column="WIDGET_ID" type="long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="string"/>
<property name="size" column="SIZE" type="int"/>
</class>
</hibernate-mapping>