...
Hibernate
...
Upgrade
Background
As of June 2012, CSF uses Hibernate version 3.2.5
...
(released
...
July
...
2007),
...
so
...
we
...
are
...
well
...
overdue
...
for
...
an
...
upgrade.
...
The
...
most
...
recent
...
Hibernate
...
version
...
is
...
4.1.4
...
(May
...
2012),
...
while
...
the
...
most
...
recent
...
release
...
in
...
the
...
3.x
...
series
...
is
...
3.6.10
...
(Feb
...
2012).
...
Our
...
long
...
term
...
goal
...
is
...
to
...
move
...
to
...
the
...
4.x
...
series,
...
but
...
several
...
issues
...
make
...
this
...
a
...
significant
...
piece
...
of
...
work.
...
One
...
of
...
the
...
issues
...
we
...
have
...
identified
...
in
...
the
...
CSF
...
code
...
that
...
makes
...
a
...
H4
...
problematic
...
is
...
the
...
reliance
...
on
...
Spring's
...
Hibernate
...
3
...
helper
...
classes
...
(HibernateDAOSupport,
...
HibernateTemplate
...
etc.).
...
For
...
several
...
years
...
now
...
(since
...
2007),
...
Spring
...
has
...
been
...
recommending
...
use
...
of
...
the
...
Hibernate
...
Session
...
API
...
rather
...
than
...
the
...
helper
...
classes,
...
and
...
Spring's
...
H4
...
support
...
actually
...
drops
...
these
...
classes
...
altogether.
...
This
...
means
...
that
...
all
...
of
...
our
...
code
...
using
...
the
...
helper
...
classes
...
will
...
have
...
to
...
be
...
refactored
...
before
...
we
...
can
...
move
...
to
...
H4.
...
To
...
prepare
...
ourselves,
...
we
...
will
...
immediately
...
start
...
work
...
on
...
this
...
refactoring,
...
while
...
staying
...
on
...
H3.
...
In
...
brief,
...
here
...
is
...
our
...
plan
...
for
...
moving
...
to
...
Hibernate
...
4:
...
- NOW:
...
- Refactor
...
- current
...
- DAO
...
- code
...
- in
...
- CSF
...
- (see
...
- below
...
- for
...
- details)
...
- SOON
...
- BUT
...
- NOT
...
- YET:
...
- Hibernate
...
- 3.6
...
- SUMMER
...
- 2013:
...
- Hibernate
...
- 4
...
- (H4)
...
Immediate
...
Refactoring
...
We
...
will
...
begin
...
refactoring
...
the
...
CSF
...
DAO
...
code
...
immediately,
...
while
...
staying
...
on
...
Hibernate
...
3.2.5.
...
We
...
will
...
remove
...
all
...
references
...
to
...
the
...
Spring
...
Hibernate
...
3
...
helper
...
classes
...
(HibernateDAOSupport,
...
HibernateTemplate
...
etc.)
...
and
...
use
...
unit
...
tests
...
to
...
verify
...
that
...
the
...
current
...
functionality
...
remains
...
intact.
...
This
...
refactoring
...
should
...
not
...
affect
...
any
...
apps
...
using
...
CSF
...
-
...
the
...
interfaces
...
and
...
functionality
...
will
...
remain
...
the
...
same;
...
we
...
are
...
just
...
refactoring
...
underlying
...
implementations.
...
IMPORTANT:
...
as
...
a
...
standard,
...
we
...
should
...
make
...
sure
...
all
...
DAOs
...
extend
...
the
...
MIT
...
class
...
AbstractHibernateDAO.
...
This
...
class
...
provides
...
an
...
abstraction
...
barrier
...
between
...
our
...
code
...
and
...
the
...
underlying
...
ORM
...
API.
...
These
...
are
...
the
...
details
...
involved
...
in
...
the
...
refactoring
...
phase:
...
1.
...
List
...
all
...
DAOs
...
in
...
CSF
...
that
...
extend
...
AbstractHibernateDAO.
...
2.
...
Refactor
...
AbstractHibernateDAO,
...
method
...
by
...
method:
Code Block |
---|
{code} DO for each method (e.g. "get"): DO for each CSF DAO in above list that uses the method (e.g. "get"): Verify there is a unit test exercising the DAO's "get" method If there is no unit test, create one and verify it passes Refactor the AbstractHibernateDAO method to use Hibernate's Session API and not Spring's HibernateTemplate END DO END DO {code} At the end of this step, the |
At the end of this step, the AbstractHibernateDAO's
...
only
...
remaining
...
dependency
...
on
...
the
...
Spring
...
H3
...
helper
...
classes
...
should
...
be
...
"extends
...
HibernateDAOSupport".
...
3.
...
Refactor
...
DAO
...
classes
...
that
...
extend
...
HibernateTemplate.
...
For
...
each
...
such
...
DAO
...
class,
...
- if
...
- any
...
- methods
...
- do
...
- not
...
- have
...
- unit
...
- tests,
...
- create
...
- the
...
- tests
...
- and
...
- verify
...
- they
...
- pass
...
- make
...
- the
...
- DAO
...
- class
...
- extend
...
- AbstractHibernateDAO
...
- replace
...
- any
...
- references
...
- to
...
- Spring's
...
- HibernateTemplate
...
- with
...
- Session
...
- API
...
- verify
...
- that
...
- unit
...
- tests
...
- still
...
- pass
At the end of this step, there should be no more references in CSF to the Spring Hibernate 3 helper classes.
4. Refactor DAO classes that are plain POJOs (i.e.
...
that
...
do
...
not
...
extend
...
any
...
other
...
class):
...
- if
...
- any
...
- methods
...
- do
...
- not
...
- have
...
- unit
...
- tests,
...
- create
...
- the
...
- tests
...
- and
...
- verify
...
- they
...
- pass
...
- make
...
- the
...
- DAO
...
- class
...
- extend
...
- AbstractHibernateDAO
...
- verify
...
- that
...
- unit
...
- tests
...
- still
...
- pass