Question

What is the difference between JpaTeplate and JpaDaoSupport (Or similar version of HibernateTemplate and HibernateDaoSupport).

I read spring documentation and spring suggest not to use this any more. I am just curious to know what is the reason behind that. One reason I understand is decoupling between spring and persistence layer. But that can not be the only reason to remove this.

Can any one put some light on it.

Thanks in advance.

Was it helpful?

Solution

In earlier days the *Template made it easier to work with the underlying technology, this was especially the case in the days of hibernate2 and early hibernate3 releases. However all these technologies have progressed and the use of the *Template doesn't make much sense anymore. It only ties your data access layer to spring without any, real, added benefit. Hence the suggestion to not use it anymore but use the plain API (i.e. JPA or Hibernate directly).

The *DaoSupport classes do some bootstrapping and/or detection for you so that you can just call the get*Template method and get a ready to use *Template. Basically the *DaoSupport allows easy access to the configured *Template and saves you from constructing one yourself.

However as mentioned in the reference guide you shouldn't be using the templates and thus support classes anymore (the only exception being the JDBC version of those).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top