Why should we use spring's hibernate? - spring

I am currently using Spring 2 + Hibernate 3.
Question 1: What is the good reason to use hibernate framework within Spring's IoC?
Question 2: Why not separate hibernate framework from Spring's IoC framework?
Question 3: For those who experienced using hibernate in Spring 3, is there any pain? (I noted that Spring 3 has much lesser configuration)
The reason why I ask this question is that I think using hibernate within Spring's IoC caused hibernate to be tightly coupled with Spring and caused the configuration file to be much complicated. Please enlighten me.

Thanks to #Wand Maker.
I have found the answer I need in the link provided: http://static.springsource.org/spring/docs/3.0.x/reference/orm.html at the 13.3 Hibernate portion which explains the different ways to implement DAO using spring hibernate.

Related

Spring JPA Hibernate Vs Spring Hibernate

Performance point of view, which one should be the better option whether Spring JPA Hibernate or Spring Hibernate ?
I do not expect any relevant Perfomance Difference between Hibernate JPA and classic Hibernate.
I don't think you should worry about it. Reasonably it is as Ralph expressed it. Instead go ahead and use JPA because your code will be vendor independent. Or go for Hibernate if you have a reason for it, (maybe better documented or something).
Hope this link helps for performance report you are looking at
http://www.jpab.org/All/All/All.html.

Spring 3 Hibernate Spring MVC Arch Type

Does anyone know of a good archytype for Spring Web MVC with Hibernate ? I have been searching and have not been able to find any ?
Kind Regards,
Muhammad Mateen
You could use appFuse: http://static.appfuse.org/archetypes.html
However, I would recommend spring ROO. Spring ROO doesn't provide archetypes, but does provide a similar skeleton setup via spring roo commands.

Spring Hibernate Connection through AOP standalone application

I am trying to develop Annotation based Spring Hibernate standalone application to connect to DB. I've gone through the some blogs and wondered like we should not make use of hibernateTemplate becoz coupling your application tightly to the spring framework. For this reason, Spring recommends that HibernateTemplate no longer be used.Further more my requirement is changed to Spring Hibernate with AOP using Declarative Transaction management.I am new to AOP concepts. Can any one please give an example on Spring Hibernate Connection through AOP. That would be a great help to me.
Thanks in advance.
If you are looking for exemples of project structures, you may want to use maven archetypes which provide you an already working Spring + Hibernate or Spring + JPA configuration.
They may provide you also a web layer (or not) but you can remove it if you want.
To try that, install maven and type:
mvn archetype:generate
By the way, I don't think using HibernateTemplate is a big deal. Many people still use it. But you'd better inject the Hibernate session factory and use contextual sessions with getCurrentSession()
I'd use JPA instead of plain Hibernate. You can of course use Hibernate as a provider. I guess that you know how to run Spring container in standalone application. Just follow the steps from documentation here. Use LocalContainerEntityManagerFactoryBean. Then read about transaction management.
There is a new feature that lets you start JPA without persistence.xml file. Read here.
If you still want to use plain Hibernate follow the docs.

Spring Framework Saving Data to Multiple Tables

Newbie here...
I'm working on a Spring MVC app and their JDBC api for data access. How would I go about saving data to multiple tables? The insertion needs to be such that if there's an error or something goes wrong, nothing gets inserted and rolled-back. Would this be Spring's transaction support? If so, the official documentation for transaction support is very confusing to me. Does anyone have a good source for learning how to do that?
I'm using Spring 3.1, Oracle 11g, and Tomcat 6.0
Yes, spring supports transaction. You can use DataSourceTransactionManager to configure your bean.IF you find xml mapping confusing you can use annotation #Transactional. Spring's annotation support for transactions are really simple. Spring in Action book has examples for transaction management.

Spring can be used in Seam?

I understand that Spring has really nice features, such as dependency injection. I am new to Spring. I have understood that I can use Spring alongside with struts and other frameworks too, in order to use its capabilities.
In my project I am going to use Seam 2.0, I am using JNDI to lookup for the EJBs. I am wondering if I can integrate Spring with Seam and use its ApplicationContext in order to get beans from that directly and not use JNDI lookup anymore?
There is a whole chapter in the Seam reference dedicated to this:
27. Spring Framework integration

Resources